[Solved] Calc Macro to setFocus to a particular cell

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
monkee09
Posts: 12
Joined: Tue Mar 10, 2015 3:29 pm

[Solved] Calc Macro to setFocus to a particular cell

Post by monkee09 »

I have a spreadsheet with an entry sheet, and several data sheets.
I have a button on the entry sheet that runs a macro that moves all of the data from the entry sheet to the various data sheets where the data belongs.
At the end of the macro, it clears the entry sheet so it's ready for the next entry.
I'm looking for a way to have it set the focus on cell C3 at the end of the macro.

This what I have and it doesn't work:
Sheet = thisComponent.Sheets.getByName("EnterData1")
Cell = Sheet.getCellRangeByName("C3")
Cell.setFocus

I've scoured the forums and haven't found an answer to this yet....
Any help would be most appreciated.
Last edited by monkee09 on Tue Mar 10, 2015 5:32 pm, edited 1 time in total.
WindowsXP, OOo3.0.0
FJCC
Moderator
Posts: 9645
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Calc Macro to setFocus to a particular cell

Post by FJCC »

I think you want

Code: Select all

Sheet = thisComponent.Sheets.getByName("EnterData1")
Cell = Sheet.getCellRangeByName("C3") 
ThisComponent.CurrentController.select(Cell)
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.
monkee09
Posts: 12
Joined: Tue Mar 10, 2015 3:29 pm

Re: Calc Macro to setFocus to a particular cell

Post by monkee09 »

Perfect! I knew it had to be something fairly simple.
WindowsXP, OOo3.0.0
Post Reply