* John Viestenz <[EMAIL PROTECTED]> [030705, 07:39]:
> bottom post:
> 
> ----- Original Message ----- 
> From: "Ennio-Sr" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Saturday, July 02, 2005 1:31 PM
> Subject: [users] Multiplesheet spreadsheet: messing up named ranges
> 
> 
> >Hi all!
> >Having some problems with named ranges in a multiplesheet environment ;(
> >The offending code seems to be the following instruction:
> >
> >------------
> >Dim oCellAddress As new com.sun.star.table.CellAddress
> >oCellAddress.Sheet = Sheet_x ' -->>>>> It was  0 <<<<<<-- ' The first 
> >sheet
> >oRanges.addNewByName(sName$,xcl$,oCellAddress,Sheet_x) ' --->>> was 0)
> >
> >'AT THIS POINT THE RANGE IS CREATED AS SH_TWO.$J$72 ?!!!!!!!!!!!!!!!
> >
> >' We arrange for copying the formula from last used row to the next one
> >dispatcher.executeDispatch(oDoc, ".uno:Copy", "", Sheet_x, Args1())
> >------------
> >
> >Say I'm on Sh_one when I execute the macro: the "Sheet_x" parameter is
> >="Sh_one" and "xcl$" carries the correct value of the cell which is being
> >'named'; all relevant values (as seen running the macro by step)
> >maintain their correct values: however, if soon after the range name is 
> >created
> >by the above reported piece of code I examine the sheets, the created
> >range name appears as belonging to another sheet, not to the one carried 
> >by
> >"Sheet_x" parameter.
> >In other words, it seems impossible to keep the named ranges sticking to
> >the sheet in which they are apparently created.
> >
> >Do you have any suggestions? May be that code is someway bugged
> >(although the full macro works correctly with single sheet
> >spreadsheets!).
> >
> >Thanks for your attention.
> >Regards,
> >Ennio
> >
> >
> Hi Ennio -- I can't answer your specific questions, but I have two 
> suggestions/questions for you to consider.  First, are you trying to assign 
> the same Name to a range on "sheet-x" that has already been assigned to 
> another range on another sheet?  I don't think OOo allows this.  If you 
> have used the name "MyRange" on sheet 1, you cannot also use the same 
> "MyRange" name on "Sheet_2".
> 
> My other thought:  Are you sure that the sheet you are trying to insert the 
> named range on, is the Active Sheet at the time the macro runs?  I use code 
> along the following, immediately before macro commands intended to be 
> applied to that specific sheet.
> 
>    oSheet = oDoc.Sheets.getByName("Sheet_")
>    oDoc.CurrentController.ActiveSheet = oSheet
> 
> (These variables had earlier been:  Dim oDoc as object, and Dim oSheet as 
> object).
> 
> -- John Viestenz 

Hi John!

The answer to your first question is "Absolutely no", as named ranges
are given like MyRange_one, MyRange_two and so one, according to the
Active Sheet as determined by previous coding instructions.
As compared to your code, this works the other way round:
my code gets the current sheet name by way of the getActiveSheet()
method, then sets the range name through a series of if condition (if
active sheet is Sh_one then range name = MyRange_one). All the strings
so determined bear correct values but the range is created in a difernet
sheet!

Thanks for your suggestions,
Ennio.

-- 
[Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo.   \\?//
 Fa' qualche cosa di cui non sei capace!"  (diceva Henry Miller) ]    (°|°)
[Why use Win$ozz (I say) if ... "even a fool can do that.              )=(
 Do something you aren't good at!" (as Henry Miller used to say) ]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to