bottom post:
----- Original Message -----
From: "Ennio-Sr" <[EMAIL PROTECTED]>
To: <users@openoffice.org>
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
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]