The following function will check to see if the reference exists in your application. It will return either true or false.
Function DoesReferenceExist( _
ByVal RName As String) As Boolean
On Error Resume Next
Dim i As Byte
Dim VBAEditor As VBIDE.VBE
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim strPrompt As String
Set VBAEditor = Application.VBE
Set VBProj = VBAEditor.ActiveVBProject
Set VBComp = VBProj.VBComponents("modVBIDE")
Set CodeMod = VBComp.CodeModule
Dim chkRef
i = 1
Do Until UCase(VBProj.References(i).Name) = UCase(RName)
If i > VBProj.References.Count Then Exit Do
i = i + 1
Loop
If i <= VBProj.References.Count Then
DoesReferenceExist = True
Else
DoesReferenceExist = False
End If
End Function
The function above can be called by the procedure below.
The procedure below will check on the existence of a reference called vba.
Sub CallDoesReferenceExist()
MsgBox DoesReferenceExist("vba")
End Sub