Use AutoCAD VBA Applications (Concept)

AutoCAD

 
Use AutoCAD VBA Applications
Concept Quick Reference
 
 
 

You load a VBA project with the VBALOAD command. Once loaded, its modules and macros are available in the Macros dialog box.

Although Microsoft applications store VBA projects, macros, and programs inside a specific document, AutoCAD uses a separate file with the .dvb extension. In this way, VBA interfaces with AutoCAD in much the same way that AutoLISP and ObjectARX do. Because VBA projects are stored in a separate file, a VBA project can open and close different AutoCAD drawings during an AutoCAD session.

NoteAutoCAD VBA projects are not binary compatible with stand-alone Visual Basic 6 projects (VBP files). However, forms, modules, and classes can be exchanged between dissimilar projects using the IMPORT and EXPORT VBA commands in the VBA integrated development environment (IDE).

You load a VBA project with the VBALOAD command. Once loaded, its modules and macros are available in the Macros dialog box. To run the VBA module you use the VBARUN command. If no VBA project is loaded, the options are unavailable. Procedures listed in the Macro Name box use the following syntax:

module.macro

In the Macros dialog box you choose the Macro Scope and select from the listed modules.

Use the Command Prompt to Run a VBA Macro

The -VBARUN command can be used to run a macro from the command prompt. This allows you to run VBA macros from the command prompt, scripts, and other AutoCAD programming environments. The only argument for the command is the module name using the module.macro syntax. The syntax looks like this:

-vbarun <module.macro>

Because macros with the same name can be duplicated in modules, the module.macro syntax differentiates the macro and allows for unique selection.