[Solved] Calc Macro to setFocus to a particular cell

Creating a macro - Writing a Script - Using the API

[Solved] Calc Macro to setFocus to a particular cell

Postby monkee09 » Tue Mar 10, 2015 3:37 pm

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
monkee09
 
Posts: 12
Joined: Tue Mar 10, 2015 3:29 pm

Re: Calc Macro to setFocus to a particular cell

Postby FJCC » Tue Mar 10, 2015 4:26 pm

I think you want
Code: Select all   Expand viewCollapse view
Sheet = thisComponent.Sheets.getByName("EnterData1")
Cell = Sheet.getCellRangeByName("C3")
ThisComponent.CurrentController.select(Cell)
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
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: 6814
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Calc Macro to setFocus to a particular cell

Postby monkee09 » Tue Mar 10, 2015 5:32 pm

Perfect! I knew it had to be something fairly simple.
WindowsXP, OOo3.0.0
monkee09
 
Posts: 12
Joined: Tue Mar 10, 2015 3:29 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests