I have an excel spreadsheet that has 8 connections. I would like to know what connection string corresponds to which datatable/pivot table in excel. A solution in 2007 or 2010 method is fine.
Is this possible?
It is possible using the Data tab.
— Click on Connections in the Data tab to bring up the Workbook Connections dialog.
— Click on a connection in the list.
— Click the link: click here to see where the selected connections are used
This is possible from VBA too. This query just enumerates them.
You can readily modify this example to refresh the queries using
Sub ShowAllQueryConnectionStrings() Dim oSheet As Excel.Worksheet For Each oSheet In Application.ActiveWorkbook.Sheets Dim oTable As Excel.QueryTable For Each oTable In oSheet.QueryTables Debug.Print "QueryTable " & oTable.Name & ": " & oTable.Connection Next Dim oPivot As Excel.PivotTable For Each oPivot In oSheet.PivotTables Debug.Print "PivotTable " & oPivot.Name & ": " & oPivot.PivotCache.Connection Next Next End Sub