To update pivot tables I use uno with this instruction:
dispatcher.executeDispatch(monDocUno, ".uno:RecalcPivotTable", "", 0, Array())
I would like not to use uno but the basic and its API to recalculate the pivot table of a calc sheet.
How we do that?
Just use the .refresh() method:
Sub refreshAllPilotTables
Dim oSheets As Variant
Dim oSheet As Variant
Dim oDataPilotTables As Variant
Dim oPilotTable As Variant
Dim i As Long
Dim j As Long
oSheets = ThisComponent.getSheets()
For i = 0 To oSheets.getCount()-1
oSheet = oSheets.getByIndex(i)
oDataPilotTables = oSheet.getDataPilotTables()
For j = 0 To oDataPilotTables.getCount()-1
oPilotTable = oDataPilotTables.getByIndex(j)
oPilotTable.refresh()
Next j
Next i
End Sub