VS2008 代码如下:
Dim cad As Autodesk.AutoCAD.Interop.AcadApplication
Private Sub activecad()
On Error Resume Next
cad = GetObject(, "AutoCAD.Application.16")
If Err.Number <> 0 Then
Err.Clear()
cad = CreateObject("AutoCAD.Application.16")
If Err.Number <> 0 Then
MsgBox(Err.Description + Chr(13) + "程序要求的CAD版本与最近" + Chr(13) + "运行的CAD版本可能不一致 。" + Chr(13) _
+ "请运行另一版本CAD试试。", vbOKOnly + vbExclamation, "Notice:")
cad = Nothing
Exit Sub
End If
End If
On Error GoTo 0
cad.Visible = True
cad.WindowState = AcWindowState.acMax
End Sub