是否将 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