我在Excel VBA用getobject 或 creatobject 启动CAD(2004),第一次总会出现错误信息,第二次才能正常,为什么?
Dim CAD as object
Private Function OpenCAD() As Boolean OpenCAD = True On Error Resume Next Set CAD = GetObject(, "AutoCAD.Application.16") If Err <> 0 Then Err.Clear Set CAD = CreateObject("AutoCAD.Application.16") 'CAD2004 If Err <> 0 Then '------- Err.Clear Set CAD = GetObject(, "AutoCAD.Application.16.1") 'CAD2005 If Err <> 0 Then Err.Clear Set CAD = CreateObject("AutoCAD.Application.16.1") If Err <> 0 Then Err.Clear MsgBox "无法启动CAD...", , "Mrqq" OpenCAD = False Exit Function End If End If '------- End If End If End Function
另外,如何在未打开CAD时得到其版本号?
谢谢! |