English 中文(简体)
libreoffice calc Macro 转而把有重点的囚室改为一间囚室的权利
原标题: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

谁能帮助?

问题回答

是否将 cur子带至右边,与 pressing右arrow一样? 然后,制作所需文字的最容易的方法是,使宏观记录能够进行,使右箭得以播放,停止宏观记录,使宏观名称具有实际意义。 其结果将与此相似。

sub moveCursorRight
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "By"
args1(0).Value = 1
args1(1).Name = "Sel"
args1(1).Value = false

dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args1())
end sub

这将真正得到完成。

采用我第一次评论中的密码,宏观法可能就是这样:

Sub jumpOneCellToRight
Dim nRow As Long, nColumn As Long, oSheet As Variant, oController As Variant 
    nRow = ActiveCell(2)
    nColumn = ActiveCell(1)
    oController = ThisComponent.getCurrentController()
    oSheet = oController.getActiveSheet()
    oController.Select(oSheet.getCellByPosition(nColumn+1,nRow))
    oController.Select(ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges"))
End Sub

Using 更短的文字

Option VbaSupport 1

Sub goRight()
     Selection.Offset(0,1).Select
End Sub




相关问题
Problem understanding how a non-static method is called

I m reading the Java code of libreoffice and there s one thing I don t really understand. The method updateUI() calls 2 time the method updateUI and they pass as a parameter a Vector variable, BUT ...

how to create an odt file programmatically with java?

How can I create an odt (LibreOffice/OpenOffice Writer) file with Java programmatically? A "hello world" example will be sufficient. I looked at the OpenOffice website but the documentation wasn t ...

热门标签