Search code examples
macroscelllibreofficecalc

libreoffice calc Macro to shift focused cell to the right by one cell


I have a cell in focus. I want to shift the focus to one cell immediately in the right using a macro. I've tried this but to no avail...

Sub move_cursor

sheet = ThisComponent.CurrentController.ActiveSheet
    cell = sheet.getCellRangeByName("A1")

    cursor = sheet.createCursorByRange(cell)
    MsgBox cursor.ImplementationName

'    Move to next cell
cursor.gotoNext()

' Trying to shift using offset to next cell on right.
cursor.gotoOffset(1, 0)

End Sub

Can anyone help?


Solution

  • I found a LibreOffice BASIC macro that works (I'm on LO 7.6) from Jim K. Get Row and Column number from "ThisComponent.CurrentSelection" in libreoffice calc basic

    But it's great that this page gives a number of diverse methods as offered by JohnSUN