cancel
Showing results for 
Search instead for 
Did you mean: 

Pivot refresh

DamianSurlicki1
Level 2
Hi, I'm a little bit stuck with pivot refresh in Excel. I did an object in Excel VBO named "Pivot Refresh" with code below: Dim wb, ws As Object Dim excel, sheet As Object wb = GetWorkbook(handle, workbookname) ws = GetWorksheet(handle, workbookname, worksheetname) wb.Activate() ws.Activate() excel = ws.Application sheet = excel.ActivateSheet sheet.PivotTables(pivotname).RefreshTable This is my last code, unfortunately not working...Check Code returns no mistakes. After execution the object I get message: "Could not execute code stage because exception thrown by code stage: The given key was not present in the dictionary. Can you help me with this problem?
4 REPLIES 4

Anonymous
Not applicable
not a great solution, but one way to do it is to create a RefreshAll macro within the workbook, then use Excel VBO ""Run Macro"".

Anonymous
Not applicable
I think the error that you have is related to the handle that you use, try to create a new Excel instance and pass its handle to your code.

AndrzejKaczor
Level 4
I am using this code: dim worksheet as object worksheet= GetWorksheet(Handle, Workbook_name, Worksheet_name) worksheet.PivotTables(pivot_name).PivotCache.Refresh And it works for me.

RohitSonawane2
Level 2
@Andrzej.Kaczor thank you!!!