S
Stewart Berman
The point of the exercise is to be able to programmatically get identifying information for broken
references. The means either the name or the fullpath -- both of which are somewhere in the
database as the VB IDE can display them.
From the reference:
Note The Microsoft® Access Application object provides a References collection and Reference
object that make it possible for you to work with references in an Access VBA project without
requiring you to establish a reference to the Microsoft Visual Basic for Applications Extensibility
5.3 type library. For more information about the Access References collection, search the Microsoft
Access Visual Basic Reference Help index for "References collection."
This does not work.
Dim objREF As VBIDE.Reference
On Error Resume Next
For Each objREF In Access.Application.VBE.ActiveVBProject.References
Debug.Print "Next Reference:"
If objREF.IsBroken Then
Debug.Print vbTab & "Missing Reference:"
Else
Debug.Print vbTab & "Reference (Not Broken):"
' The Description property generates
' a run-time error if a VBIDE Reference
' object is broken, so the following
' code line is only included here for
' unbroken references.
Debug.Print vbTab & " Description: " & objREF.description
End If
Debug.Print vbTab & " Name: " & objREF.Name
Debug.Print vbTab & " FullPath: " & objREF.FullPath
Debug.Print vbTab & " Type: " & objREF.Type
Debug.Print vbTab & " BuiltIn " & objREF.BuiltIn
Debug.Print vbTab & " IsBroken: " & objREF.IsBroken
Debug.Print vbTab & " GUID: " & objREF.Guid
Debug.Print vbTab & " Major: " & objREF.Major
Debug.Print vbTab & " Minor: " & objREF.Minor
Debug.Print
Next
Set objREF = Nothing
This produces (with the first three not broken references deleted):
Next Reference:
Reference (Not Broken):
Description: Microsoft Forms 2.0 Object Library
Name: MSForms
FullPath: C:\WINDOWS\system32\FM20.DLL
Type: 0
BuiltIn False
IsBroken: False
GUID: {0D452EE1-E08F-101A-852E-02608C4D0BB4}
Major: 2
Minor: 0
Next Reference:
Missing Reference:
Type: 0
BuiltIn False
IsBroken: True
GUID: {4E4AC072-D051-EB92-1D54-8DC5C371C9CD}
Major: 1
Minor: 0
You will notice that if the reference is broken the Name and FullPath also generates a run-time
error which is why they are not displayed..
The Reply-To header of my message has a valid email address. If you send me an email with a valid
return address I would be happy to send you the database to play with.
references. The means either the name or the fullpath -- both of which are somewhere in the
database as the VB IDE can display them.
GeoffG said:
From the reference:
Note The Microsoft® Access Application object provides a References collection and Reference
object that make it possible for you to work with references in an Access VBA project without
requiring you to establish a reference to the Microsoft Visual Basic for Applications Extensibility
5.3 type library. For more information about the Access References collection, search the Microsoft
Access Visual Basic Reference Help index for "References collection."
This does not work.
I changed the code slightly to:2.
Here's a variation of Tony Toews code:
Dim objREF As VBIDE.Reference
On Error Resume Next
For Each objREF In Access.Application.VBE.ActiveVBProject.References
Debug.Print "Next Reference:"
If objREF.IsBroken Then
Debug.Print vbTab & "Missing Reference:"
Else
Debug.Print vbTab & "Reference (Not Broken):"
' The Description property generates
' a run-time error if a VBIDE Reference
' object is broken, so the following
' code line is only included here for
' unbroken references.
Debug.Print vbTab & " Description: " & objREF.description
End If
Debug.Print vbTab & " Name: " & objREF.Name
Debug.Print vbTab & " FullPath: " & objREF.FullPath
Debug.Print vbTab & " Type: " & objREF.Type
Debug.Print vbTab & " BuiltIn " & objREF.BuiltIn
Debug.Print vbTab & " IsBroken: " & objREF.IsBroken
Debug.Print vbTab & " GUID: " & objREF.Guid
Debug.Print vbTab & " Major: " & objREF.Major
Debug.Print vbTab & " Minor: " & objREF.Minor
Debug.Print
Next
Set objREF = Nothing
This produces (with the first three not broken references deleted):
Next Reference:
Reference (Not Broken):
Description: Microsoft Forms 2.0 Object Library
Name: MSForms
FullPath: C:\WINDOWS\system32\FM20.DLL
Type: 0
BuiltIn False
IsBroken: False
GUID: {0D452EE1-E08F-101A-852E-02608C4D0BB4}
Major: 2
Minor: 0
Next Reference:
Missing Reference:
Type: 0
BuiltIn False
IsBroken: True
GUID: {4E4AC072-D051-EB92-1D54-8DC5C371C9CD}
Major: 1
Minor: 0
You will notice that if the reference is broken the Name and FullPath also generates a run-time
error which is why they are not displayed..
The Reply-To header of my message has a valid email address. If you send me an email with a valid
return address I would be happy to send you the database to play with.