Chapter 37. Programming with Visual Basic for Applications
Visual Basic for Applications (VBA) is a programming language and environment that is included with many Microsoft applications, such as Word, Excel, PowerPoint, and Access. Since Release 14, VBA has been available with AutoCAD as well. VBA is ideally suited for situations in which you need to work with more than one application at a time. ActiveX, which I discussed in the last chapter in relation to Visual LISP, enables you to access objects in other applications. However, you can also use VBA to program AutoCAD alone. This chapter introduces you to VBA and shows how you can start to use this powerful language to customize AutoCAD.
Note
AutoCAD LT does not support VBA. This entire chapter applies to AutoCAD only.
Visual Basic for Applications is a variation of Visual Basic. Visual Basic is not related to any specific application. Visual Basic code is compiled into an executable file that stands alone, unrelated to any specific document. VBA, on the other hand, is connected to its application and the document in which you created the code. VBA provides a simple way to customize AutoCAD, automate tasks, and program applications from within the application.
VBA in AutoCAD works slightly differently from VBA in most other applications, in that VBA projects are stored in a separate file, with the DVB filename extension, but can also be stored within the drawing file.
Starting to Work with VBA
After you decide to program AutoCAD, the ...
Get AutoCAD® 2009 & AutoCAD LT® 2009 Bible now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.