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?
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