[Solved] Accessing the the 'active' cell

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
ajotatxe
Posts: 3
Joined: Fri Sep 27, 2019 4:22 pm

[Solved] Accessing the the 'active' cell

Post by ajotatxe »

I'm trying

Code: Select all

cell = ThisDocument.getCurrentSelection()
And then cell is an ScCellObj

Then when I try

Code: Select all

y = cell.CellAddress.Row
I get the error 'Property or method not found: CellAdress'

But I have inspected 'cell' like so

Code: Select all

msgbox cell dbg_properties
And I can see a property SbxOBJECT CellAddress
Last edited by robleyd on Sun Sep 29, 2019 1:01 pm, edited 3 times in total.
Reason: Add green tick
OpenOffice 4 on windows 10
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

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

Post by FJCC »

Are you sure you spelled CellAddress correctly? You have it misspelled twice, two different ways, in your post.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
ajotatxe
Posts: 3
Joined: Fri Sep 27, 2019 4:22 pm

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

Post by ajotatxe »

In my code I wrote "adress". Thanks.
OpenOffice 4 on windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Post 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.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
ajotatxe
Posts: 3
Joined: Fri Sep 27, 2019 4:22 pm

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

Post by ajotatxe »

Villeroy wrote: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.
"
OpenOffice 4 on windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Post 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())
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply