【发布时间】:2016-02-24 04:42:17
【问题描述】:
如何将 Excel VBA 宏移植到 OpenOffice 基本宏?
这里是每 5 秒刷新一次的宏。
Private Sub Workbook_Open()
' Written in ThisWorkbook
Call RefreshTime
End Sub
Sub RefreshTime()
' Written in a module
Application.ScreenUpdating = False
ActiveWorkbook.RefreshAll
Application.OnTime Now + TimeValue("00:00:05"), "RefreshTime"
Range("B10").Value = "My Current Time of the System:"
Range("C10").Value = Format(Now, "hh:mm:ss AM/PM")
Beep
Application.ScreenUpdating = True
End Sub
我尝试将此宏转换为 OpenOffice 宏(使用 http://www.business-spreadsheets.com/vba2oo.asp)
Private Sub Workbook_Open()
' Written in ThisWorkbook
Call RefreshTime
End Sub
Sub RefreshTime()
' Written in a module
ThisComponent.LockControllers
ThisComponent.RefreshAll
Application.OnTime Now + TimeValue("00:00:05"), "RefreshTime"
ThisComponent.CurrentController.ThisComponent.CurrentController.ActiveSheet.getCellDim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1)ByName(("B10")).Value = "My Current Time of the System:"
ThisComponent.CurrentController.ThisComponent.CurrentController.ActiveSheet.getCellDim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1)ByName(("C10")).Value = Format(Now, "hh:mm:ss AM/PM")
Beep
ThisComponent.UnlockControllers
End Sub
这行代码导致语法错误的是:
ThisComponent.CurrentController.ThisComponent.CurrentController.ActiveSheet.getCellDim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1)ByName(("B10")).Value = "My Current Time of the System:"
但有错误
基本语法错误。预期:,。
在 oSheet 中作为对象。
如何让它在 OpenOffice 中运行?
【问题讨论】:
-
又是哪一行代码导致语法错误?
-
这行代码导致语法错误:oSheet in ThisComponent.CurrentController.ActiveSheet.getCellDim oSheet as Object
-
谢谢,这将对了解 OO Basic 的人有所帮助。由于您是新手,您可能不知道可以单击问题下方的“编辑”按钮来添加其他信息。在这种情况下,我已经为您完成了 :-) 祝您迁移顺利!
标签: vba excel openoffice-basic