请问在VBA中如何调用CAD程序打开DWG文件
<p>请问在VBA中如何调用CAD程序打开DWG文件</p><p>ShellExecute 0, "open", dwgfile, vbNullString, vbNullString, vbNormalFocus //运行不通过,提示没有这个函数定义</p><p>Shell "acad.exe " + dwgfile //找不到acad.exe文件</p><p>Shell "c:\program files\autocad2005\acad.exe" + dwgfile //这样可以运行,但是把路径写死了:(</p><p>有个办法:找到acad.exe程序路径,但不知道如何寻找</p> <p>通过注册表可以找到ACAD.exe的路径,但如果要打开某一个DWG,在VBA中,你不能直接使用thisdrawing.open ,或者ThisDrawing.Application.Documents.Open来打开图吗?</p> <p>你是想用VB还是想用VBA,是Office的VBA还是CAD的VBA?</p><p>Private WithEvents acadApp As AcadApplication<br/>Private WithEvents acadDoc As AcadDocument<br/>Set acadApp = GetObject(, "AutoCAD.Application")<br/>If Err Then<br/> Err.Clear<br/> Set acadApp = CreateObject("AutoCAD.Application")<br/> If Err Then<br/> MsgBox "ErrorNumber:" & Err.Number & vbNewLine & "Source:" & Err.Source & vbNewLine & Err.Description, 16 ' "无法运行AutoCAD2000,请检查是否安装了AutoCAD 2000", 16<br/> Set acadApp = Nothing<br/> End<br/> End If<br/>End If<br/>acadApp.WindowState = acMax<br/>acadApp.Visible = True<br/>Set acadDoc = acadApp.Documents.Add '添加文档<br/>acadDoc.Open "c:\aa.dwg"</p>
页:
[1]