* Ennio-Sr <[EMAIL PROTECTED]> [310505, 01:37]:
> * Ennio-Sr <[EMAIL PROTECTED]> [300505, 01:02]:
> > * Ennio-Sr <[EMAIL PROTECTED]> [290505, 17:10]:
> > > 
> > > * Andrew Douglas Pitonyak <[EMAIL PROTECTED]> [280505, 18:56]:
> > > > 
> > > > [skip]
> > > > 

Hi Andrew and other macro experts. I made some progress:
the macro I wrote is not very elegant but I feel I'm getting near the
final result: 'Print xcls$' now shows correctly the selected cell as
'$C$3'; the point is: Why the named range is not created?
Where is the error? Can you help?

>-------------
>Sub Macro1

>Dim oRange 'The created range
>Dim oRanges ' All named ranges
>Dim sName$ ' Name of the named range to create
>Dim oActiveCell 'The current active cell
>Dim oConv ' The Cell address conversion service
>rem Dim xCell as Object
>rem ###
>'oRanges2 = ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
>rem oRanges2 = 
>ThisComponent.createInstance("com.sun.star.table.CellRangeAddress")
>rem Dim oActiveCell As new com.sun.star.table.CellRangeAddress

>ThisComponent.CurrentController.Select(oRanges2)
>oActiveCell = ThisComponent.CurrentSelection
>rem oActiveCell = 
>ThisComponent.createInstance("com.sun.star.table.XCellRowAddress")
>oConv = 
>ThisComponent.createInstance("com.sun.star.table.CellAddressConversion")
>oConv.Address = oActiveCell.getCellAddress

>Print oConv.UserInterfaceRepresentation
>xCell =  oConv.PersistentRepresentation
>'c$ = oActiveCell.celladdress.column
>r$ = oActiveCell.celladdress.row+1
>dim xcl$
>xcl$ = "Sheet1.$C$"+r$
>print xcl$
>rem Dim xCell As new oConv.UserInterfaceRepresentation
>sName$ = "last_bal"
>oRanges = ThisComponent.NamedRanges
>If NOT oRanges.hasByName(sName$) Then
>Dim oCellAddress As new com.sun.star.table.CellAddress
>    oCellAddress.Sheet = 0 'The first sheet
>oRanges.addNewByName(sName$,xcl$,oCellAddress,0)    
>rem oRanges.addNewByName(sName$,"$Sheet1.$F$15",oCellAddress,0)
>End If
>oRange = ThisComponent.NamedRanges.getByName(sName$)
>----------------

Regards,
       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