bob_0377 发表于 2005-7-12 16:33:00

open打开图形,没有打开,新手弱弱的问,在线等ing!

本帖最后由 作者 于 2005-7-12 17:15:37 编辑 <br /><br /> <P>Private Sub Form_Load()</P>
<P>Dim acadapp As Object&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '建立Application对象<BR>Dim acaddoc As Object&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '建立Document对象<BR>Dim mospace As Object&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '建立Model Space 对象<BR>On Error Resume Next</P>
<P>Set acadapp = GetObject(, "autocad.application")&nbsp;&nbsp; '若AutoCad已启动 , 则直接得到</P>
<P>If Err Then<BR>&nbsp;&nbsp; Err.Clear<BR>&nbsp;&nbsp; Set acadapp = CreateObject("autocad.application")&nbsp;&nbsp; '若AutoCad未启动,则运行它<BR>&nbsp;&nbsp; If Err Then<BR>&nbsp;&nbsp;&nbsp;&nbsp; MsgBox Err.Description<BR>&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<BR>&nbsp;&nbsp; End If<BR>End If</P>
<P>acadapp.Visible = True&nbsp; '使AutoCad可见<BR>Set acaddoc = acadapp.ActiveDocument&nbsp;&nbsp; '设acaddoc为当前图形文件<BR>Set mospace = acaddoc.ModelSpace&nbsp; '设mospace为当前图形文件的模型空间</P>
<P>Dim dwgname As String<BR>dwgname = "D:\课题\新疆油田\石南21电子文档归档\工艺\DL222加0\DL122加5\DWG22加5.dwg"<BR>If Dir(dwgname) &lt;&gt; "" Then<BR>&nbsp;&nbsp;&nbsp;&nbsp; acaddoc.Open dwgname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '打开一个CAD文件<BR>Else<BR>&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "File " &amp; dwgname &amp; " does not exist."</P>
<P>End If</P>
<P>End Sub</P>
<P>请各位大侠帮忙!小弟感激不尽!</P>
<P>我用的是AutoCAD2005&nbsp;&nbsp; 操作系统是简体中文XP</P>
<P><BR>&nbsp;</P>

wyj7485 发表于 2005-7-12 16:52:00

End Sub前少个end if

bob_0377 发表于 2005-7-12 17:17:00

<P>不好意思,拷贝的时候掉了。</P>
<P>我现在修改过来还是不行啊!</P>
<P>请再指点!</P>
<P>静侯!</P>

雪山飞狐_lzh 发表于 2005-7-12 20:13:00

<P>&nbsp;&nbsp;set&nbsp; objDoc = ACadApp.Documents.Open("c:\1.dwg")<BR></P>

bob_0377 发表于 2005-7-12 21:25:00

lzh741206发表于2005-7-12 20:13:00static/image/common/back.gif
set objDoc = ACadApp.Documents.Open(\"c:\1.dwg\")

多谢<EM>lzh741206斑竹的指点,小弟 的问题已经解决!!!</EM><BR>
页: [1]
查看完整版本: open打开图形,没有打开,新手弱弱的问,在线等ing!