Create New Menus

AutoCAD ActiveX

 
Create New Menus
 
 
 

To create a new menu, use the Add method to add a new PopupMenu object to the PopupMenus collection.

To create a new shortcut menu, you must delete an existing shortcut menu. There can be only one shortcut menu per menu group. If there is no other shortcut menu in a menu group, you can add a menu with the label “POP0”. This will tell AutoCAD you want to create a shortcut menu.

The Add method requires as input the name (label) of the menu to add. This name becomes the title for the menu when it is loaded on the menu bar. The name is also the easiest way of identifying the menu within the collection.

The menu name can be a simple string or it can contain special codes. You can change the name of a menu once it has been created. To change the name of an existing menu, use the Name property for that menu.

Create a new popup menu

This example creates a new popup menu called “TestMenu” in the first menu group of the MenuGroups collection.

Sub Ch6_CreateMenu()
 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")
End Sub