LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Refresh pivot - catch 22?

I have a problem that is stumping me€¦

The default address for the data on my PC is \Tom\Docs\Reporting.

I want it to be \*User*\Docs\Reporting.

Ive tried to update the pivots automatically on open, in ThisWorkbook
module. The code I'm running (below) is lifted straight from the other
modules, so I know it should work. But that's not the problem I don't think.


Public SpecialPathMyDocs As String ' ref GetSpecialFolderMyDocs

Private Sub Workbook_Open()

' set SpecialPathMyDocs as default My Documents folder

Dim WshShell As Object

Set WshShell = CreateObject("WScript.Shell")
SpecialPathMyDocs = WshShell.SpecialFolders("MyDocuments")

'Open folder in Explorer
'MsgBox SpecialPathMyDocs

' set default path for all pivot tables as default MyDocs folder in order to
allow refresh

Sheets("Files Data").Activate

Range("B9").Select

' this is the line that chooses source address
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"'" & SpecialPathMyDocs & "\Reporting\[Data UK YTD.xls]UK'!$A:$BC"

With ActiveSheet.PivotTables("PivotTableF1").PivotField s("Category")
.PivotItems("FILES").Visible = True
End With
' refresh pivot
ActiveSheet.PivotTables("PivotTableF1").PivotCache .Refresh

End Sub



The above code results in a runtime error on workbook open: I cant update
the default pivot data address without first refreshing the pivots (hence the
error).

Heres the catch 22. I cant refresh the pivots if the default address isnt
where the data is stored. Obviously on my PC it's already correct, so the
code works with the refresh command first, but won't work if I move the
report to another PC (as is the intention).

The only way I can think would be to save the data with the pivots, which
therefore negates the need to refresh the data before changing the address in
the above code, but also makes the report file massive. I can then write a
macro to remove the "save data with table" before saving.

Is there a better way around this problem?
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
slow document / pivot table refresh and pivot function Justin Larson[_2_] Excel Discussion (Misc queries) 1 April 2nd 09 06:41 PM
Create refresh button in worksheet to refresh Pivot Table Data Ron Excel Worksheet Functions 1 October 13th 07 01:20 AM
refresh a new worsheet on pivot table refresh [email protected] Excel Worksheet Functions 0 February 9th 07 07:39 PM
Timing of automatic query refresh and macro pivot table refresh dutty Excel Programming 2 December 1st 04 07:19 PM
Pivot Table REFRESH Flaw -- Saves Old Data in Selection Area AFTER REFRESH Ken Roberts Excel Programming 3 September 11th 03 06:02 AM


All times are GMT +1. The time now is 10:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"