zjn0987 发表于 2008-3-28 10:34:00

AutoCAD2002与visual basic 6.0如何连接?

AutoCAD2000和visual basic的连接书上有,可我的是2002的,用那个程序不好用,不知道怎么连接了,请大家帮帮忙,谢谢

兰州人 发表于 2008-3-28 13:34:00

<p>与版本无关。</p><p>给段程序理解一下。</p><p>On Error Resume Next<br/>Set obj_Acad = GetObject(, "autocad.application")<br/>If Err Then<br/>&nbsp;&nbsp; Err.Clear<br/>&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp; Set obj_Acad = CreateObject("autocad.application")<br/>&nbsp;&nbsp; If Err Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Err.Clear<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "不能运行AutoCAD,请检查是否安装!", vbOKCancel, "警告!"<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Function<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>End If<br/>obj_Acad.Visible = True<br/>Set obj_Doc = obj_Acad.ActiveDocument<br/>Set obj_ModelSpace = obj_Doc.ModelSpace<br/>'MsgBox "运行结束!", vbOKOnly, "工程1!"<br/>boo = True</p><p></p>

zjn0987 发表于 2008-3-28 14:04:00

<p>好用,谢谢!</p><p>Exit Sub应该是</p><p>不是Exit Function</p>
页: [1]
查看完整版本: AutoCAD2002与visual basic 6.0如何连接?