On Error Resume Next
Set ACADApp = GetObject(, "autocad.application")
If Err Then
Err.Clear
Set ACADApp = CreateObject("autocad.application")
If Err Then
MsgBox ("系统无法运行AutoCAD,请检查是否正确安装了AutoCAD")
Exit Sub
End If
End If
End Sub
Private Sub Command1_Click() ‘显示cad窗口
ACADApp.Visible = True
ACADApp.WindowState = acMax
End Sub
Private Sub ACADApp_BeginQuit(Cancel As Boolean) ’询问cad的关闭时间
If MsgBox("AutoCAD即将关闭。要继续关闭", vbYesNo + vbQuestion) <> vbNo Then
Cancel = False
End If
End Sub