我希望能够根据用户输入日期跳转到单元格(在B14中)。
在F列中,我有一个日期列表(从第8行开始)。
到目前为止,我有private SimpleMessageListenerContainer container;
(在B15中)计算正确日期所在的行,并返回一个数字。
我需要在LibreOffice VBA中编写一个宏,它将在G列中选择该行中的单元格。到目前为止,我有:
=MATCH(B14,F8:F373)+7
但它不接受表格中的值(列,行)。我之前看到过我需要sub jump
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
Doc = ThisComponent
Sheets=Doc.Sheets
sheet=Sheets.getByName("ThisYear")
dim args1(0) as new com.sun.star.beans.PropertyValue
thisrow =sheet.getCellByPosition(15,2).getValue()
args1(0).Name = "ToPoint"
args1(0).Value = (G,thisrow)
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
end sub
这样的东西,但我怎么能包含变量呢? (我尝试使用7而不是G,但这并没有帮助。)
我已经提到了工作表名称args1(0).Value = "G15"
,但它完全在一张纸上,所以理想情况下我不想指定这个,所以我可以在不同的工作表中使用宏。
我是VBA的新手,所以请回复整个分组。
谢谢!
答案 0 :(得分:0)
我知道您在查找如何更改LibreOffice Calc中的单元格选择时遇到问题。这是一个代码片段,向您展示如何操作。简而言之,您确定了一个目标范围(oRange
)(下面是位于3,3
的单个单元格),然后将该对象传递给.select()
方法。
Sub ChangeSelection
oSheets = ThisComponent.Sheets
oSheet = oSheets.getByIndex(0)
oRange = oSheet.getCellByPosition(3,3)
ThisComponent.CurrentController.select(oRange)
End Sub
LibreOffice使用UNO API记录here。如果要浏览对象的属性和方法,请使用MsgBox oObject.DBG_properties
或.DBG_methods
,通常最终可以找到正确的内容。您问题中的代码段会返回一个我无法立即弄清楚的错误。