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