Option Explicit
Sub ListAllCheckedRefs()
Dim oLibRefs As Object
Dim wkb As Workbook
Dim wks As Worksheet
Dim i As Long
Set wkb = ThisWorkbook
Set wks = wkb.ActiveSheet
On Error GoTo NoAccess
With wks
.Range("A1").Value = "References from Excel version " & _
Application.Version & " for " & ThisWorkbook.Name
.Range("A2:F2").Value = _
Array("Description", "Name", "GUID", "Major", "Minor", "Path")
i = 1
For Each oLibRefs In wkb.VBProject.References
i = i + 1
.Cells(1 + i, 1).Value = oLibRefs.Description
.Cells(1 + i, 2).Value = oLibRefs.Name
.Cells(1 + i, 3).Value = oLibRefs.GUID
.Cells(1 + i, 4).Value = oLibRefs.Major
.Cells(1 + i, 5).Value = oLibRefs.Minor
.Cells(1 + i, 6).Value = oLibRefs.FullPath
Next oLibRefs
.Columns("A:F").EntireColumn.AutoFit
.Range("A1:F2").Font.Bold = True
.Range("A1").Select
End With
Set wkb = Nothing
Set wks = Nothing
Exit Sub
NoAccess:
Select Case Err.Number
Case 1004
Cells.Clear
MsgBox "You will need to set the " & _
"{ TRUST ACCESS TO VISUAL BASIC PROJECT } setting" & vbNewLine & _
"When the dialog appears, go to the Trusted Sources tab, " & _
"check the setting, click OK, and rerun this code again", 64
SendKeys "%T", True
SendKeys "M", True
SendKeys "S", True
Case Else
Cells.Clear
MsgBox Err.Description
End Select
End Sub
|