A macro is a series of commands that executes specific actions when a menu item is selected. Menu macros can simply be recordings of keystrokes that accomplish a task, or they can be a complex combination of commands, AutoLISP, DIESEL, or ActiveX programming code.
Once a menu item has been created, you can change the macro for the menu item using the Macro property.
This example creates a new menu called â€śTestMenuâ€ť and inserts a menu item. The menu item is given the name â€śOpen,â€ť and the macro assigned to the menu item is the OPEN command.
Dim currMenuGroup As AcadMenuGroup
Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
' Create the new menu
Dim newMenu As AcadPopupMenu
Set newMenu = currMenuGroup.Menus.Add("TestMenu")
' Add a menu item to the new menu
Dim newMenuItem As AcadPopupMenuItem
Dim openMacro As String
' Assign the macro the VBA equivalent of "ESC ESC _open "
openMacro = Chr(3) + Chr(3) + "_open "
Set newMenuItem = newMenu.AddMenuItem _
(newMenu.count + 1, "Open", openMacro)
' Display the menu on the menu bar
(ThisDrawing.Application.menuBar.count + 1)