All menu items share the following properties:
- TagString
-
A tag, or name tag, is a string consisting of alphanumeric and underscore (_) characters. This string uniquely identifies the menu item within a given menu. Tags identify the accelerator keys (keyboard key sequences) that correspond to the menu item.
You can read or write the value of a tag by using the TagString property.
- Label
- Caption
- Macro
-
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.
You can read or write the value of a menu macro by using the Macro property.
- HelpString
- Enable
-
Using the Enable property, you can enable or disable a menu item. You can also read the Enable property to determine if a menu item is currently enabled or disabled. Using this property to enable or disable a menu item overrides any setting for enabling in the DIESEL expression of the menu item.
See Explore the Properties of Menu Items for an example of disabling menu items.
- Check
- Index
-
The index of a menu item specifies the position of that menu item on the menu on which it belongs. The index position of a menu always begins with position 0. For example, if the item is the first item on a menu, it returns an index position of 0. If it is the second item on a menu, it returns an index position of 1 and so on.
- Type
-
You can determine the type of a menu item by using the Type property. A menu item can be one of the following types: a regular menu, a separator, or the heading for a submenu. If the item is a regular menu item, this property returns acMenuItem. If the item is a separator, this property returns acMenuSeparator. If the item is a heading for a submenu, this property returns acSubMenu.
- SubMenu
-
You can find the submenu by using the SubMenu property. If the menu item is of the type acSubMenu, this property returns the menu that is attached as the submenu, or embedded menu. The embedded menu is returned as a PopupMenu object.
If the menu item is not of the type acSubMenu, this property returns an error.
- Parent
This example creates a new menu called “TestMenu” and inserts two menu items. The second menu item is then disabled using the Enable property and the menu is displayed on the menu bar.
Sub Ch6_DisableMenuItem()
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 two menu items and a menu separator to the new menu
Dim MenuEnable As AcadPopupMenuItem
Dim MenuDisable As AcadPopupMenuItem
Dim MenuSeparator As AcadPopupMenuItem
Dim openMacro As String
' Assign the macro the VB equivalent of "ESC ESC _open "
openMacro = Chr(3) + Chr(3) + "_open "
Set MenuEnable = newMenu.AddMenuItem _
(newMenu.count + 1, "OpenEnabled", openMacro)
Set MenuSeparator = newMenu.AddSeparator("")
Set MenuDisable = newMenu.AddMenuItem _
(newMenu.count + 1, "OpenDisabled", openMacro)
' Disable the second menu item
MenuDisable.Enable = False
' Display the menu on the menu bar
newMenu.InsertInMenuBar _
(ThisDrawing.Application.menuBar.count + 1)
End Sub