Macros (VBA for AutoCAD)

AutoCAD Scripting

Introduction to VBA for AutoCAD

VBA stands for Visual Basic for Applications. It is a custom version of the Visual Basic programming language that has powered AutoCAD Macros since the mid-2000s. This programming interface of AutoCAD will let you,

  • Create and Execute Macros (explained in the next section). Almost everything that the user can do in AutoCAD from the user interface can be done by writing code in VBA for AutoCAD.
  • Integrate AutoCAD with other applications such as Microsoft Excel, Word, PowerPoint, Outlook, Notepad etc.

What is a Macro ?

Macros are codes written in VBA (Visual Basic for Applications) which helps to reduce the manual effort required for a job. Macros save your time and headaches by automating common, repetitive tasks. They reduce the possibility of human error that increases with many, repetitive keystrokes and tasks. The most important feature of an AutoCAD macro is, it can be saved for future use, shared among multiple users.

In a layman’s language, a macro is a recording of your routine steps in AutoCAD that you can replay using a single button

The best part is You don’t have to be a programmer or know Visual Basic Applications (VBA) to use Macros. You just need to copy the codes shared here and hit the run button to execute them. Save the file as DVB file for future use.

How to use codes shared here?

  • Step 1: Copy the Code shared here.
  • Step 2: Click on Tools Tab in the Menu bar of AutoCAD.
  • Click on Macros, then Visual Basic Editor. ALT + F11 is the Shortcut for Visual Basic Editor.
  • Step 3: Right click on the tree view and Insert a Module.
  • Step 4: Paste the Code given here into a module.
  • Step 5: Close the editor and Click on Macros in Developer Tab. You will get a dialogue box with the list of Macros ready for execution. Click on Run button to execute the macro.

Ready to use Macros

Create Text in AutoCAD Drawing
Extract X, Y, Z Coordinates of Points in an AutoCAD Drawing
Extract X, Y, Z Coordinates of Blocks in an AutoCAD Drawing
Extract details of Text Objects in an AutoCAD Drawing
Extract Coordinates of 2D Polyline (LW Polyline)
Extract Area of Polygons and Polylines
Extract Area of Circles
Extract Coordinates of a 3D Polyline

Things to remember while using Macros

  • VBA is no longer installed by default in AutoCAD. To download VBA pack for AutoCAD, visit
  • We cannot Undo an action performed using Macro. Make sure that you have a backup of the data before executing the macro.
  • For future use the AutoCAD macro as DVB file.
  • Always fill in the description of the macro when creating one. This will help you understand your own work if you have to revisit it weeks or months later.

Join online Course on AutoCAD VBA Programming

Programming in AutoCAD
Programming in AutoCAD

Scripting in AutoCAD

Tips & Tricks in AutoCAD

Command Alias in AutoCAD

Complete list of AutoCAD Commands