you want to do something like (untested):
Code:
Public Sub buildRefs()
Call assertRef("C:\Program Files\Microsoft Office\Office11\XLStart\Book1.xla")
Call assertRef("C:\windows\system32\msxml2.dll")
End Sub
Private Sub assertRef(fileSpec As String)
If Not addRef(fileSpec) Then
debug.print "Reference to " & fileSpec & " was unsuccessful"
End If
End Sub
Private Function addRef(fileSpec As String) As boolean
On Error Resume Next
If Not doesRefExist(fileSpec) Then
activeWorkbook.VBProject.References.AddFromFile fileSpec
End If
addRef = (Err.Number = 0)
End Function
private Function doesRefExist(fileSpec As string) As Boolean
Dim ref As Object
For Each ref In ThisWorkbook.VBProject.References
If StrComp(ref.FullPath, fileSpec, vbTextCompare) = 0 Then
doesRefExist = True
Exit For
End If
Next
End Function
ie. running the "buildRefs" procedure adds references to an XLA addin, and a DLL. Is this what you mean?