[Solved] Accessing the the 'active' cell

Creating a macro - Writing a Script - Using the API

[Solved] Accessing the the 'active' cell

Postby ajotatxe » Fri Sep 27, 2019 4:32 pm

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
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
ajotatxe
 
Posts: 3
Joined: Fri Sep 27, 2019 4:22 pm

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

Postby FJCC » Fri Sep 27, 2019 5:08 pm

Are you sure you spelled CellAddress correctly? You have it misspelled twice, two different ways, in your post.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7354
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

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

Postby ajotatxe » Sat Sep 28, 2019 6:40 am

In my code I wrote "adress". Thanks.
OpenOffice 4 on windows 10
ajotatxe
 
Posts: 3
Joined: Fri Sep 27, 2019 4:22 pm

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

Postby Villeroy » Sat Sep 28, 2019 5:14 pm

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, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27296
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Postby ajotatxe » Sun Sep 29, 2019 12:35 pm

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.
"
OpenOffice 4 on windows 10
ajotatxe
 
Posts: 3
Joined: Fri Sep 27, 2019 4:22 pm

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

Postby Villeroy » Sun Sep 29, 2019 1:36 pm

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, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27296
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests