About Accessing the Object Hierarchy (VBA/ActiveX)

Accessing the object hierarchy is easy from within VBA. This is because VBA is running in-process with the current AutoCAD session so there is no additional step needed to connect it to the application.

VBA provides a link to the active drawing in the current AutoCAD session through the ThisDrawing object. By using ThisDrawing you gain immediate access to the current Document object and all of its methods and properties, and all of the other objects in the hierarchy.

When used in global projects, ThisDrawing always refers to the active document in AutoCAD. When used in embedded projects, ThisDrawing always refers to the document containing the project. For example, the following line of code in a global project saves whatever drawing is currently active in AutoCAD:

ThisDrawing.Save