Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh PowerPivot with vbs script

Status
Not open for further replies.
Nov 21, 2013
1
PL
Hello everyone,

I have an excel spreeadsheet with powerpivot data, which needs to be copied and refreshed twice a week.
I managed to write a script that makes a copy of the spreadsheet, but I don't know how to refresh powerpivot data.
I googled the problem and found method QueryTable.Refresh, but it doesn't work.
Here is my code:
Code:
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("my_spreadsheet.xlsx")
objExcel.Application.Visible = False
objExcel.Application.DisplayAlerts = False
objExcel.ActiveWorkbook.SaveAs "my_spreadsheet_" & Date & ".xlsx",51
objExcel.QueryTable.Refresh
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
WScript.Quit

Can anyone help me?
Thanks in advance!
 
Have you tried pivot cache refresh e.g. something like objworksheet.PivotTables("PivotTable1").PivotCache.Refresh ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top