a dvb is a compiled file, not just the text you see in the ide. It gets compiled for the specific version of acad you're using and won't work on other versions. When you open up a dvb for 2024 in 2025, it automatically gets the reference to the acad tlb updated to the current version of the tlb. You can't use a dvb for 2024 on 2025 without it being upgraded, and therefore unusable to 2024. You need a separate dvb for 2025 and one for 2024. If you are trying to create an instance of acad in Excel, then your xl code has to account for different versions. You either have to develop two spreadsheets, one that references acad 2024 and one that references acad 2025, or determine at runtime which acad tlb to reference. If you want to do it programmatically, you can use the function below. It requires setting a reference to "Microsoft 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
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.