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