PRB: You Cannot Change the Data Source for a PivotTable in Excel for an Analysis Services Connection (327572)
The information in this article applies to:
- Microsoft Excel 2000
- Microsoft SQL Server 2000 (all editions)
- Microsoft SQL Server 2000 Analysis Services
This article was previously published under Q327572 SYMPTOMS
After you change the server name of the computer that is running Analysis Services that an Excel PivotTable is using, you cannot manually change the connection information to the new folder or server.
WORKAROUNDNOTE: Microsoft has tested the following code sample on Excel 2000.
To work around this problem, use Visual Basic for Applications to programmatically change the data source for a PivotTable in Excel for an Analysis Services connection:
- Start Excel 2000.
- Open the file that contains the PivotTable (or PivotTables) that you want to modify.
- On the Tools menu, point to Macro, and then click Visual Basic Editor.
- On the Insert menu, click Module.
- In the module, insert the following macro code:
Option Explicit
Sub ChangeServer()
Dim sh As Worksheet, qy As QueryTable
Dim pt As PivotTable, pc As PivotCache
Dim OldPath As String, NewPath As String
Dim strOld As String, strNew As String
' 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 = "<old server name>"
NewPath = "<new server name>"
For Each sh In ActiveWorkbook.Sheets
For Each pt In sh.PivotTables
strOld = pt.PivotCache.Connection
strNew = Replace(strOld, OldPath, NewPath)
pt.PivotCache.Connection = strNew
pt.PivotCache.Refresh
Next pt
Next sh
End Sub
- Change OldPath and NewPath to the appropriate server name. If you use a server that does not exist for NewPath, the multidimensional connection wizard opens when you perform step 12 of this procedure.
- On the File menu, click Close, and then return to Microsoft Excel.
- Switch to the first sheet.
- On the Tools menu, point to Macro, and then click Macros.
- In the list of macros, select the ChangeServer macro, and then click Run.
- A dialog box opens in which you can change the server and that lists the available cubes. Changing the cube does not change the cube for your queries that are using this code.
- The dialog box opens for each of the PivotTables in turn.
- Update your PivotTable server name.
- Save the spreadsheet. You may want to remove the macro before you distribute the spreadsheet.
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbprb KB327572 |
---|
|