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: 7
Default Try to change the path of the Query of pivot table in Excel 2000

Dear all,

I tried to change the folder location of access database
that a query or PivotTable using according to the article
269619, During the refreshing of data, i see two access
database lock files, one in my local harddisk(NewPath) and
another one in the server(old Path).

it looks like to me that I am actually using the new data
in the new path, but i am still having the connection with
the old access database in the network server.

Thanks
victor

=======================================
Dim sh As Worksheet, qy As QueryTable
Dim pt As PivotTable, pc As PivotCache
Dim OldPath As String, NewPath As String
Sub QueryChange()
'Replace the following paths with the original path or
server name where
'your database resided, and the new path or server name
where your database
'now resides.
OldPath = "\\oldserver\OldPath\Folder"
NewPath = "C:\NewPath\Folder"
For Each ws In ActiveWorkbook.Sheets
For Each qy In ws.QueryTables
qy.Connection = _
Application.Substitute(qy.Connection, _
OldPath, NewPath)
qy.Sql = _
StringToArray(Application.Substitute(qy.Sql,
_
OldPath, NewPath))
qy.Refresh
Next qy
For Each pt In ws.PivotTables
pt.PivotCache.Connection = _
Application.Substitute(pt.PivotCache.Connection, _
OldPath, NewPath)
pt.PivotCache.Sql = _
StringToArray(Application.Substitute
(pt.PivotCache.Sql, _
OldPath, NewPath))
pt.PivotCache.Refresh
Next pt
Next ws
End Sub

Function StringToArray(Query As String) As Variant
Const StrLen = 127
Dim NumElems As Integer
Dim Temp() As String
NumElems = (Len(Query) / StrLen) + 1
ReDim Temp(1 To NumElems) As String
For i = 1 To NumElems
Temp(i) = Mid(Query, ((i - 1) * StrLen) + 1,
StrLen)
Next i
StringToArray = Temp
End Function

 
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
View/Change Pivot Table Query ToniS Charts and Charting in Excel 5 November 13th 08 01:31 PM
Pivot Table Source Data File Path Change AndrewEdmunds Excel Discussion (Misc queries) 1 November 10th 08 06:45 PM
Q: Change pivot table source path? Mark Excel Discussion (Misc queries) 1 July 27th 06 12:40 AM
In Excel 2000, How can I change the order in a pivot table? Confused... Charts and Charting in Excel 0 May 26th 06 07:47 PM
Change the path of a Microsoft Query? MWH Excel Worksheet Functions 1 January 29th 06 12:54 PM


All times are GMT +1. The time now is 10:24 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"