Page 1 of 1
[Solved] Accessing the the 'active' cell
Posted: Fri Sep 27, 2019 4:32 pm
by ajotatxe
I'm trying
Code: Select all
cell = ThisDocument.getCurrentSelection()
And then cell is an ScCellObj
Then when I try
I get the error 'Property or method not found: CellAdress'
But I have inspected 'cell' like so
And I can see a property SbxOBJECT CellAddress
Re: Accessing the the 'active' cell (with keyboard focus)
Posted: Fri Sep 27, 2019 5:08 pm
by FJCC
Are you sure you spelled CellAddress correctly? You have it misspelled twice, two different ways, in your post.
Re: Accessing the the 'active' cell (with keyboard focus)
Posted: Sat Sep 28, 2019 6:40 am
by ajotatxe
In my code I wrote "adress". Thanks.
Re: Accessing the the 'active' cell [Solved]
Posted: Sat Sep 28, 2019 5:14 pm
by Villeroy
viewtopic.php?f=20&t=86922&p=406973#p406973 gets the active cell of a view even when a range, multiple ranges or shapes are selected.
Re: Accessing the the 'active' cell [Solved]
Posted: Sun Sep 29, 2019 12:35 pm
by ajotatxe
Nice solution, but how could one figure out about this 'ViewData' property and its structure and meaning? I have searched but in the API Reference it only says that
"set special view state
Data to set a special view state after loading. The type depends on the component and is usually retrieved from a ::com::sun::frame::Controller object by its ::com::sun::frame::XController interface. Default is: no view data."
Re: [Solved] Accessing the the 'active' cell
Posted: Sun Sep 29, 2019 1:36 pm
by Villeroy
No macro coding without object inspection tool.
MRI tutorial
The XRay tool
In 99% of all use cases you want the active cell in ThisComponent's active window: oCell = getActiveCell(ThisComponent.getCurrentController())