Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Pivot Table Update Error: The cube file cannot be opened for writing.

Avatar of tmassoglia01
tmassoglia01 asked on
Microsoft OfficeMicrosoft Excel
7 Comments1 Solution1462 ViewsLast Modified:
I am trying to programmatically update multiple pivot tables in an Excel spreadsheet.  These pivot tables all point to the same Access database.  I can update the first one fine, but when I try to update any of the other pivot tables I get the following error: "The cube file C:\Sales Budget 2007\Sales Budget Cube Detail.cub cannot be opened for writing.".  I also get this same error when trying to manually update each of the pivot tables.  If I save it, close Excel, then re-open I am able to update the next pivot table.  I am curently using this code to auto-update the pivot tables:
____________________________________________________________________________________
Sub Refresh_All_PTs()
On Error Resume Next
Application.EnableEvents = False
Dim ws As Worksheet
Dim Pt As PivotTable
If MsgBox("Do you wish to update ALL PivotTables in this workbook?", _
vbYesNo + vbQuestion + vbDefaultButton2, "Refresh PivotTables?") = vbNo Then Exit Sub
Application.StatusBar = "Updating PivotTables in current workbook!"
For Each ws In ActiveWorkbook.Worksheets
For Each Pt In ws.PivotTables
Pt.PivotCache.Refresh
If Err.Number <> 0 Then
MsgBox Err.Description
Err.Number = 0
End If
Next
Next
Application.StatusBar = False
Application.EnableEvents = True

End Sub
____________________________________________________________________________________

Any help in getting this to work would be appreciated.

Thanks,
Tony