About Customizing AutoCAD With VBA

Microsoft® Visual Basic® for Applications (VBA) software provides application integration with other VBA-enabled applications.

AutoCAD-based products can be used as an Automation controller for other applications such as Microsoft Word or Excel.

Note: VBA is no longer installed by default. For more information, visit http://www.autodesk.com/vba-download.

VBA sends messages using the AutoCAD ActiveX Automation Interface. AutoCAD VBA permits the Visual Basic environment to run simultaneously with AutoCAD and provides programmatic control of AutoCAD through the ActiveX Automation Interface. This linking of AutoCAD, ActiveX Automation, and VBA provides an extremely powerful interface. It not only controls AutoCAD objects, it also can send data to or retrieve data from other applications.

Before you can edit or run a macro from a VBA project, it must be loaded into AutoCAD first. VBA projects are stored in separate files with the .dvb extension, and are composed of code and class modules, and forms. Since VBA projects are stored in a separate file, a VBA project can open and close different AutoCAD drawings during a session which cannot be done with AutoLISP.

Note: VBA projects are not binary compatible with Visual Basic projects (VBPROJ) files created with Visual Studio.

Fundamental elements of AutoCAD VBA

Three fundamental elements define VBA programming in AutoCAD.

Advantages of using VBA

The AutoCAD ActiveX/VBA interface provides several advantages over other AutoCAD API environments: