code to check for project references in VBA

  • Thread starter Thread starter Qasim Ahmad
  • Start date Start date
Q

Qasim Ahmad

Hi everyone,

Can someone please help me out here. I'm trying to check is all the
project references are valid for a VBA piece of code i have written
and need to distribute. Currently, if there is a broken reference,
the vba just ends up spiting out a runtime error. Is there an elegant
way to check for this through the code. I did see examples using
VBPRoject, but i am not using this object. im using pure vba.
Thanks in advance :)
 
Qasim,

Sub testit()
Dim ref As Object

For Each ref In ThisWorkbook.VBProject.References
If ref.IsBroken Then Debug.Print ref.Name & " is broken"
Next
End Sub

Rob
 
Thanks! another problem i was having was that i was not referencing
the Microsoft Visual Basic Extensibitiy library, which allows me to
use the VBProject object. Once i figured that out, the code below
works. thanks again.
 
Back
Top