Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List all Data Connections, Workbook Connections and Calculated Fields in Workbook

Status
Not open for further replies.

BxWill

MIS
Mar 30, 2009
367
US
Relative novice at VBA and just created the following two sets of code to extract all data connections, workbook connections
and calculated fields in a MS Excel workbook that contains over 10 data models (using Power Pivot against a SQL Server Database).

Have been at it for over a hour and I need to obtain some assistance/insight to ensure that I am approaching this correctly.

What modifications to the code below are necessary to enable the accomplishment of the objective?

Code:
Sub ListLinks()
Dim wb As Workbook
Set wb = Application.ActiveWorkbook

alinks = ActiveWorkbook.LinkSources(xlExcelLinks)
    
If Not IsEmpty(alinks) Then
    
    wb.Sheets.Add
    xIndex = 1
    For Each link In wb.LinkSources(xlExcelLinks)
        Application.ActiveSheet.Cells(xIndex, 1).Value = link
        xIndex = xIndex + 1
    Next link
End If
End Sub


Sub ListConnectionsTwo()
Dim wb As Workbook

Dim conn As WorkbookConnection  '-added

Set wb = Application.ActiveWorkbook
   
'acon = ActiveWorkbook.Connections  'added
   
If Not IsEmpty(acon) Then
   
    wb.Sheets.Add
    xIndex = 1
    For Each acon In wb.Connections
        Application.ActiveSheet.Cells(xIndex, 1).Value = acon
        xIndex = xIndex + 1
    Next acon
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top