Private Sub Form_Initialize() If Left(Version, 2) = "15" Then Set objDBX = CreateObject("ObjectDBX.AxDbDocument.1") ElseIf Left(Version, 2) = "16" Then Set objDBX = CreateObject("ObjectDBX.AxDbDocument.16") End If End Sub
Dim objDBX As AxDbDocument On Error Resume Next Set objDBX = CreateObject("ObjectDBX.AxDbDocument.1") If err Then err.Clear Set objDBX = CreateObject("ObjectDBX.AxDbDocument.15") If err Then err.Clear Set objDBX = CreateObject("ObjectDBX.AxDbDocument.16") If err Then err.Clear Set objDBX = CreateObject("ObjectDBX.AxDbDocument.17") If err Then err.Clear Set objDBX = CreateObject("ObjectDBX.AxDbDocument.18") End If End If End If End If On Error GoTo 0 我一般是这样用的,因为我也分不清"."后面到底要多少才好!
Set AcadObj = GetObject(, "autocad.application.16") If Err Then MsgBox "没有打开AutoCAD 2004" Unload Me Else ' SetParent Me.hwnd, AcadObj.hwnd End If Set DbxObj = AcadObj.GetInterfaceObject("ObjectDBX.AxDbDocument.16")