Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

PRB: You Cannot Change the Data Source for a PivotTable in Excel for an Analysis Services Connection


View products that this article applies to.

This article was previously published under Q327572

↑ Back to the top


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.

↑ Back to the top


Workaround

NOTE: 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:
  1. Start Excel 2000.
  2. Open the file that contains the PivotTable (or PivotTables) that you want to modify.
  3. On the Tools menu, point to Macro, and then click Visual Basic Editor.
  4. On the Insert menu, click Module.
  5. 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
    					
  6. 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.
  7. On the File menu, click Close, and then return to Microsoft Excel.
  8. Switch to the first sheet.
  9. On the Tools menu, point to Macro, and then click Macros.
  10. In the list of macros, select the ChangeServer macro, and then click Run.
  11. 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.
  12. The dialog box opens for each of the PivotTables in turn.
  13. Update your PivotTable server name.
  14. Save the spreadsheet. You may want to remove the macro before you distribute the spreadsheet.

↑ Back to the top


Keywords: KB327572, kbprb

↑ Back to the top

Article Info
Article ID : 327572
Revision : 10
Created on : 2/20/2007
Published on : 2/20/2007
Exists online : False
Views : 447