Page 1 of 1

[Solved] Calc Macro to setFocus to a particular cell

Posted: Tue Mar 10, 2015 3:37 pm
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.

Re: Calc Macro to setFocus to a particular cell

Posted: Tue Mar 10, 2015 4:26 pm
by FJCC
I think you want

Code: Select all

Sheet = thisComponent.Sheets.getByName("EnterData1")
Cell = Sheet.getCellRangeByName("C3") 
ThisComponent.CurrentController.select(Cell)

Re: Calc Macro to setFocus to a particular cell

Posted: Tue Mar 10, 2015 5:32 pm
by monkee09
Perfect! I knew it had to be something fairly simple.