You create and run a VBA macro from either AutoCAD Map or the Visual Basic Editor.
To create and run a macro from AutoCAD Map
1 Choose Tools > Macro > Macros.
2 Type the name of the macro, for example Hello.
3 Click Create.
4 Select a project or drawing.
5 Between the Sub Hello and End Sub statements, type the following code:
6 Choose Run > Run Sub/User Form to run the code. To step through the code, put the cursor between the Sub and End Sub statements, and press F8. To run the code, choose Run > Run Sub.
To create and run a macro from the Visual Basic Editor
1 Double-click ThisDrawing in the Project Explorer.
2 Choose Insert > Procedure and type the name for the procedure. For example, type Hello.
3 Between the Sub Hello and End Sub statements, type the following code:
4 To step through the code, put the cursor between the Sub and End Sub statements, and press F8. To run the code, choose Run > Run Sub.