Sub Ch2_ConnectToAcad()
On Error Resume Next
’ 连接至 AutoCAD 应用程序
Dim tmCAD As AcadApplication
Set tmCAD = GetObject _
(, "AutoCAD.Application.16")
If Err Then
Err.Clear
Set tmCAD = CreateObject _
("AutoCAD.Application.16")
If Err Then
MsgBox Err.Descri ption
Exit Sub
End If
End If
’ 连接至 AutoCAD 图形
tmCAD.Visible = True ’ 隐式地打开
tmCAD.Documents.Open "c:\123.dwg"
Set sSet = tmCAD.ActiveDocument.SelectionSets.Add("TEST")
tmCAD.ActiveDocument.SendCommand "_ai_selall" & Chr(13)
tmCAD.ActiveDocument.Export app.Path & "tempcad", "WMF", sSet
tmCAD.ActiveDocument.SelectionSets.Item("TEST").Delete
Picture1.Picture = LoadPicture(app.Path & "tempcad.wmf")
tmCAD.Documents.Close
tmCAD.Quit
Set tmCAD = Nothing
End Sub
[此贴子已经被作者于2007-9-27 8:06:30编辑过]