2012

Table Of Contents
AutoCAD VBA
Microsoft Visual Basic for Applications (VBA) is an object-based programming
environment designed to provide rich development capabilities. The main
difference between VBA and VB (Visual Basic 6) is that VBA runs in the same
process space as AutoCAD, providing an AutoCAD-intelligent and very fast
programming environment.
Overview of AutoCAD VBA
VBA provides application integration with other VBA-enabled applications.
This means that AutoCAD, using other application object libraries, can be an
Automation controller for other applications such as Microsoft Word or Excel.
NOTE Microsoft
®
Visual Basic
®
for Applications software (VBA) is no longer installed
with AutoCAD. For more information, visit http://www.autodesk.com/vba-download.
The stand-alone development editions of Visual Basic 6, which must be
purchased separately, complement AutoCAD VBA with additional components
such as an external database engine and report-writing capabilities.
Develop with AutoCAD VBA
VBA sends messages to AutoCAD by 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, but it also sends data to or retrieves data from other
applications.
The integration of VBA into AutoCAD provides an easy-to-use visual tool for
customizing AutoCAD. For example, you can create an application that extracts
attribute information automatically, inserts the results directly into an Excel
spreadsheet, and performs any data transformations you need.
Three fundamental elements define VBA programming in AutoCAD. The first
is AutoCAD itself, which has a rich set of objects that include AutoCAD entities,
data, and commands. AutoCAD is an open-architecture application with
multiple levels of interface. To use VBA effectively, familiarity with AutoCAD
programmability is highly desirable. However, you will find that the VBA
object-based approach is quite different from that of AutoLISP.
428 | Chapter 7 Introduction to Programming Interfaces