Hi Julian,
I see three possible solutions to this. The first two don't require adding any references.
1. Several customers that I know of have an ivb file that they create and use company wide. When they write new utilities in VBA, they create them in this project and then deploy the updated ivb file to the user's computers (or update a single shared version of the file). In this case you would just add the reference to this project and then everyone gets it automatically.
2. You can use "late binding". With this approach, instead of declaring variables to be of a specific type you can declare them to be of type "Object". At runtime, VBA will get the object returned and perform "late binding" to figure out what type of object it is and what functions the object supports. All of your code should work as expected. The downside to this approach is that while your writing your code you don't get any code hints and at runtime the execution will be slightly slower. But I would guess the performance hit in your case won't even be noticable.
3. From the Inventor API you can access the API for the VBA Development Environment. Using that API you can add references. Below is a small test case I wrote that does this. It defines the reference by specifying the full path to the dll you want to reference. There is also an AddFromGuid method that you can use if that's easier in your case. One thing to be aware of is that to be able to use any of the classes defined in the VBIDE library I had to first reference the "Microsoft Visual Basic for Applications Extensibility 5.3" library. This is because I declared them as specific objects from the VBIDE library. Instead, I could use late binding for those objects, like what I discussed above.
Public Sub AddReference()
Dim invVBAProj As Inventor.InventorVBAProject
Set invVBAProj = ThisApplication.VBAProjects.Item(1)
Dim VBAProj As VBIDE.VBProject
Set VBAProj = invVBAProj.VBProject
' Ignore any errors because it's throwing an exception even when it succeeds.
On Error Resume Next
Dim path As String
path = "C:\Windows\System32\cryptext.dll"
Call VBAProj.References.AddFromFile("C:\Windows\System32\cryptext.dll")
On Error GoTo 0
' Check the reference exists.
Dim ref As VBIDE.Reference
Dim succeeded As Boolean
succeeded = False
For Each ref In VBAProj.References
If UCase(ref.FullPath) = UCase(path) Then
succeeded = True
Exit For
End If
Next
If Not succeeded Then
MsgBox "Failed to add referenced to """ & path & """"
End If
End Sub