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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBAProject Referencing (How?) 1

Status
Not open for further replies.

TopJack

Programmer
Mar 10, 2001
153
GB
How can I check in VBA that a VBProject reference is available for Excel to use.

I run some code that needs a project reference to the "Microsoft DAO 3.51 Object Library" installed. I need to ensure that it is 'checked' ready for use, otherwise my code doesn't work.

The closest I have come is this .......

Application.VBE.ActiveVBProject.References.Item(?)

Any help would be appreciated.
 
The following will return a MessageBox that lists all of the references in a VBA Project and it will tell you if teh Microsoft DAO 3.51 Object Library is installed:

Code:
Sub InstalledReferences()
Dim i As Integer
Dim msg As String
On Error Resume Next
For i = 1 To 40
   msg = msg & Application.VBE.ActiveVBProject. _
         References.Item(i).Description & vbCrLf
Next
' MsgBox msg, vbOKOnly, "Installed References"
If Not msg Like "*Microsoft DAO 3.51 Object Library*" Then
    MsgBox "Microsoft DAO 3.51 Object Library" & vbCrLf & _
        "is not installed in this VBA Project!", , "Reference Missing"
End If
End Sub

I hope this helps!

Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Absolutely perfect - I didn't think I explained it very well.

".Description" ...... Doohhh ! ..... Of course. I couldn't see the wood for the trees.

Thanks a lot Mike. A star is coming your way.
 
I'm glad I could help!

[wavey]


Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top