Page 1 of 1

[Solved] Accessing the the 'active' cell

PostPosted: Fri Sep 27, 2019 4:32 pm
by ajotatxe
I'm trying

Code: Select all   Expand viewCollapse view
cell = ThisDocument.getCurrentSelection()

And then cell is an ScCellObj

Then when I try
Code: Select all   Expand viewCollapse view
y = cell.CellAddress.Row

I get the error 'Property or method not found: CellAdress'

But I have inspected 'cell' like so
Code: Select all   Expand viewCollapse view
msgbox cell dbg_properties

And I can see a property SbxOBJECT CellAddress

Re: Accessing the the 'active' cell (with keyboard focus)

PostPosted: 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)

PostPosted: Sat Sep 28, 2019 6:40 am
by ajotatxe
In my code I wrote "adress". Thanks.

Re: Accessing the the 'active' cell [Solved]

PostPosted: 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]

PostPosted: Sun Sep 29, 2019 12:35 pm
by ajotatxe
Villeroy wrote:https://forum.openoffice.org/en/forum/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.


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::star::frame::Controller object by its ::com::sun::star::frame::XController interface. Default is: no view data.
"

Re: [Solved] Accessing the the 'active' cell

PostPosted: 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())