我要在WORD中调用AutoCAD,打开一张autoCAD的图。
我自己试了一种方法:在WORD中的“引用”中添加对autocad的引用(AUTOCAD 2000 TYPE LIBRORY),
并编写如下程序如下:
Public Sub cad()
Dim app As AutoCAD.AcadApplication
Set app = New AutoCAD.AcadApplication
app.Visible = True
app.Documents.Open "d:\TEST.DWG"
End Sub
Dim acadApp As AcadApplication
On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set acadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
acadApp.Documents.Open "d:\TEST.DWG"
acadApp.Visible = True
End If
谢谢南子的出手相救。
我后来试了一下。
问题出题还是出在acadApp.Visible=ture,
应该是acadApp.application.Visible=Ture.
程序
Public Sub cad()
Dim app As AutoCAD.AcadApplication
Set app = New AutoCAD.AcadApplication
app.Application.Visible = True
app.Documents.Open "d:\TEST.DWG"
End Sub
可以运行通过,AUTOCAD显示正常。