Incorporating VBA Modules VBA macros allow you to add custom AutoCAD
commands to accomplish repetitive or complicated tasks not available as native
AutoCAD commands. VBA programming is beyond the scope of this article, but we
review various methods to incorporate VBA macros into your work. In our example,
we'll be using the ad_PlotLayouts macro
available in the VBA section of this site. If the macro is one that you will only use
occasionally, you may choose to load and execute it as-needed. To do this, first
load the macro into memory with the command 'vbaload'. This presents you with
the 'Open VBA Project' dialog:
This article reviews incorporating VBA macros and modules into your work.
Copyright©2000-2007 ActiveDwg.com
There are several ways to utilize VBA macros. For our purposes,
we'll presume you've downloaded the ad_PlotLayouts
VBA module. First you should download and/or place the file into a folder in
AutoCAD's File Support path (such as 'Acad2002\Support').
The simplest method to access and execute the VBA macro is to create a new
toolbar button and in it's macro section place a statement to demand
load the macro: '-vbarun;ad_PlotLayouts.dvb!ad_PlotLayouts'. Note that this
statement includes both the VBA module file and the VBA macro within the file.
The statement performs the dual purpose of loading the VBA module into memory
and executing the macro within the module.

Locate and Highlight the file by single-clicking it, and click the 'Open' button:

The VBA module is now loaded into memory and may be executed. This is done by
issuing the command 'vbarun'. This presents the 'Macros' dialog which lists the
currently loaded VBA modules. Highlight the module to be executed and click the
'Run' button:

This will execute the macro.
Another, more unwieldy, method is to add the VBA macro file to the AutoCAD
startup suite so that it is automatically loaded each time AutoCAD is started.
We don't support this method because it loads modules into memory whether or not
they will be used. If you have a particular need to load your modules this way,
please let us know, and we'll be happy to provide the necessary steps.