Hi Eike,

* Eike Rathke <[EMAIL PROTECTED]> [040705, 16:59]:
> Hi Ennio-Sr,
> 
> On Sat, Jul 02, 2005 at 19:31:04 +0200, Ennio-Sr wrote:
> 
> > 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)    
> 
> What is the content of xcl$?
(Pls see below)

> Btw, you're misusing the 4th parameter, it
> should be a set of bit constants, and only works here by incident
> because Sheet_x==0.
> 
I was just going to search documentation to get further info about that
(I remember having read that "0" meant the first sheet, but couldn't
find where, yet ;-(  )

> > 'AT THIS POINT THE RANGE IS CREATED AS SH_TWO.$J$72 ?!!!!!!!!!!!!!!!
> 
> I assume that the sheet name used in xcl$ is not an absolute address.

And you're are perfectly right, as usual!
Sheet_x is a parameter which gets its value according to the current
active sheet in a separate function; then, back in the main code:

   dispatcher.executeDispatch(oDoc, ".uno:GoUp", "", Sheet_x, args1())
   ' we determine the row number of the selected cell: 
   ' numbering starts from 0, so we need add 1:
   r$ = oCell.CellAddress.row+1
   xcl$ = "$"+Sheet_x+".$J$"+r$   ' xcl$ --> $Sh_two.$J$10 at the moment

Once I added the "$" before Sheet_x, everything seems to work as it
should :-)

> Contrary to Excel, Calc distinguishes between absolute and relative
> sheet names, so if you insert a name referring Sheet_x when your active
> sheet is Sheet_x and then switch to Sh_two and view the defined name
> you'll see Sh_two. If you don't want that, prefix the sheet name with
> a '$' dollar sign.

Hmm, I never used Excel ... and started experimenting OOo multisheet
with a view to, hopefully, speed up operativeness: the single 7 separate
sheets work very well but take a lot to load/unload (they have crossed
references to get summary situation of all seven accounts).
What baffled me was that "xcl$" correctly reported the sheet name which
was being changed internally by the:
  oRanges.addNewByName(sName$,xcl$,oCellAddress,Sheet_x) ' --->>> was 0)    
instruction.
Thanks to your suggestion I replaced the 4th parameter (Sheet_x) with an
integer parameter, that gets its numeric value (0, 1, 2, etc) according
tothe Sheet_x name
> 
> > In other words, it seems impossible to keep the named ranges sticking to
> > the sheet in which they are apparently created.
> 
> True. Defined names are global to the document.
> 
>   Eike
> 

Thank you very much indeed, Eike, for your help: it saved me a huge
(desperate) research for that 4th parameter ;-)

Regards,
        Ennio.

---------
PS [OT]:
I'm now testing a parallel macro to safely close the spreadsheet with a
correct last balance named range. Once completed, I think the whole lot
could  be used to complement the existing document on multiplesheets
(I don't have under my fingers the link Peter Kupfer suggested a few
days ago). Whom should I contact?

-- 
[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