If you want more help, you'll need to show some code. I'm not sure what you mean by 'global scope'. If you want to connect to 2017, then using my function, it would look like.
Set acapp = GetAcad(".21.0")
You should be able to have multiple versions of acad installed with multiple versions of the vba enabler. They are version independent. However, in your xl app, you can only reference one acad tlb at a time. If you want xl to support multiple versions of acad, then you need to determine what version is installed and set a reference at runtime. So, during development, set a reference and get all your bugs ironed out. Then when deploying, remove the reference and set it at runtime using the function below.You have to reference "Visual Basic for Applications Extensibility 5.3".
Public Function SetReferenceByFile(FilePath As String, Optional DisplayErrors As Boolean) As VBIDE.Reference
'returns True if successful in setting a reference in the current dvb,
'given the FilePath of a tlb, olb, dll. The DisplayErrors option determines
'whether or not an error message will be displayed upon erroring.
On Error GoTo ErrorHandler
Dim objVB As Object 'VBE
Dim objRef As VBIDE.Reference
Dim objRefs As VBIDE.References
Dim strPath As String
Set objVB = AcadApplication.VBE
Set objRef = objVB.ActiveVBProject.References.AddFromFile(FilePath)
SetReferenceByFile = True
GoTo Finish:
ErrorHandler:
If Err.Number = 32813 Then
'reference was already set, just return the reference
Set objRefs = objVB.ActiveVBProject.References
For Each objRef In objRefs
If objRef.FullPath = FilePath Then
Set SetReferenceByFile = objRef
End If
Next objRef
Else
If DisplayErrors = True Then
MsgBox Err.Number & ", " & Err.Description, vbExclamation, "SetReferenceByFile."
Else
End If
Set SetReferenceByFile = Nothing
End If
Finish:
Set objVB = Nothing
Set objRef = Nothing
End Function
The other way is to use late binding, i.e. declare acapp as Object and let vba determine the data type at runtime. Again, for development, to take advantage of Intellisense, set a reference to one tlb and write your code. Then just before deployment, change all the acad data types to Object.
Ed
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to
post your code.