问题描述
我正在尝试从 LibreOffice 7.1 运行 Excel VBA 宏,该宏在此处中断:
Dim pt As PivotTable
For Each pt In ActiveSheet.PivotTables
pt.RefreshTable
Next pt
ActiveSheet.Range("C3").Select
End Sub
函数 pt.RefreshTable
显然不存在于 calc 上,有谁知道我该如何替换它?
解决方法
您应该使用 Refresh 方法而不是 RefreshTable
。还要注意 .getDataPilotTables()
和 .PivotTables
Sub updatePivotData
Dim oActiveSheet As Variant
Dim oDataPilotTables As Variant
Dim oTable As Variant
oActiveSheet = ThisComponent.getCurrentController().getActiveSheet()
oDataPilotTables = oActiveSheet.getDataPilotTables()
For Each oTable in oDataPilotTables
oTable.refresh()
Next oTable
End Sub