我有一个焦点所在的单元格。我想使用宏将焦点立即转移到右侧的一个单元格。 我已经尝试过了,但没有效果...
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
有人可以帮忙吗?
将光标向右移动一个单元格与按右箭头相同吗?然后创建所需脚本的最简单方法是启用宏录制,按向右箭头,停止宏录制,为宏指定一个有意义的名称。结果将是类似于此的代码
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
这将真正完成工作。 但是按右箭头不是更容易吗?