' 連接至 AutoCAD 應用程式
Dim acadApp As AcadApplication
acadApp = CType(GetObject _
(, "AutoCAD.Application.17"), AcadApplication)
If CBool(Err.Number) Then
Err.Clear()
acadApp = CType(CreateObject _
("AutoCAD.Application.17"), AcadApplication)
If CBool(Err.Number) Then
MsgBox(Err.Description)
Exit Sub
End If
End If
' 連接至 AutoCAD 圖面
Dim acadDoc As AcadDocument
acadDoc = acadApp.ActiveDocument
acadApp.Visible = True
acadDoc.Application.ZoomExtents() '極放圖面