- Home
- Producten
- Bedrijfsbehoeften
- Partners
- Referenties
- Kenniscentrum
- Support
- Over Perrit
- Handleidingen
- Nieuws
- Acties
Dim sh As Worksheet, qy As QueryTable Dim pt As PivotTable, pc As PivotCache Dim OldPath As String, NewPath As String Sub QueryChange() 'Vervang de volgende paden door het oorspronkelijke pad of de naam van de server waar 'de database was opgeslagen, en het nieuwe pad of de nieuwe server waar de database'nu is opgeslagen. OldPath = "C:\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
Relevante artikelen |
Gekoppelde tagsCache, Database, Excel, Excel 2000, Excel 2002, Excel 97, Foutbericht, Procedure, Query, SQL, Tabel, Visual Basic, Werkblad, Works |