View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_2_] Dick Kusleika[_2_] is offline
external usenet poster
 
Posts: 66
Default How do I update a ODBC query in Excel using pivotTables in VBA

FCS wrote:
Thanks for your reference. I have made some tests and it seems that the
mdw file name is stored in the PT. It can be seen in the PivotCahe
Connection property and it follows the format "SystemDB=<file". Any
idea on how can I force it to read again the entry from the DSN?


Yes, you can recreate the pivot table. That option stinks, I'm sure you'll
agree. You can change the location of the db in the pivottable. It doesn't
'read' it from the DSN, but it has the same effect.

Sub Changedbloc()

Const sOLDPATH As String = "C:\OldFolder\"
Const sNEWPATH AS String = "C:\NewFolder\"

With Sheet1.PivotTables(1).PivotCache
.Connection = Replace(.Connection, sOLDPATH, sNEWPATH)
.Refresh
End With
End Sub


--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com