[Solved] Macro to GOTO a Cell using Row:Column NUMBERS?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
alf50
Posts: 131
Joined: Sun Jun 13, 2010 2:55 pm

[Solved] Macro to GOTO a Cell using Row:Column NUMBERS?

Post by alf50 »

Does anyone have an example Macro to GOTO a cell that I have just written a Number In. All the examples seem to use Row/Column ID's like A5, rather than the equivalent X,Y coordinates of the Cell (IE: 0,4)?
Last edited by alf50 on Tue Nov 27, 2012 4:33 am, edited 1 time in total.
OpenOffice 4.1.14 on Mac Catalina(10.15.7), RasPi4B (TwisterOS-8/2023update) & MS Wnds10
FJCC
Moderator
Posts: 9558
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Macro to GOTO a Cell using Row:Column NUMBERS?

Post by FJCC »

There is a getCellByPosition() method. A macro would look like

Code: Select all

oSheets = ThisComponent.Sheets
oSheet = oSheets.getByName("Sheet1")
oCell = oSheet.getCellByPosition(0,4)
I'm not sure that you need to Go To (that is, select) that cell. There is no need to select the cell for most macro purposes.
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.
JohnV
Volunteer
Posts: 1585
Joined: Mon Oct 08, 2007 1:32 am
Location: Kentucky, USA

Re: Macro to GOTO a Cell using Row:Column NUMBERS?

Post by JohnV »

To have oCell become the active one add this line to FJCC's code.

Code: Select all

ThisComponent.CurrentController.Select(oCell)
Post Reply