Use the Help files....
In 2004
The following code example uses the Clear and Description properties of Err. If your coding environment does not support these properties, you will need to modify the example appropriately: Sub Ch2_ConnectToAcad() Dim acadApp As AcadApplication On Error Resume Next Set acadApp = GetObject(, "AutoCAD.Application.16") If Err Then Err.Clear Set acadApp = CreateObject("AutoCAD.Application.16") If Err Then MsgBox Err.Description Exit Sub End If End If MsgBox "Now running " + acadApp.Name + _ " version " + acadApp.Version End Sub
Next, set the document variable to the Document object in the AutoCAD application. The Document object is returned by the ActiveDocument property of the Application object. Dim acadDoc as AcadDocument Set acadDoc = acadApp.ActiveDocument
From this point on, use the acadDoc variable to reference the current AutoCAD drawing.
|