MenuItems Method

Applies To

Menu Object.

Description

Accessor. Returns an object that represents a single menu item (a MenuItem object or Menu object, Syntax 1), or a collection of the menu items ( a MenuItems object, Syntax 2) on the menu. Read-only.

This method returns a MenuItem object when the menu item is a command or separator bar, and it returns a Menu object when the menu item is a submenu caption.

Syntax 1

object.MenuItems(index)

Syntax 2

object.MenuItems

object

Required. The Menu object.

index

Required for Syntax 1. The name or number of the menu item.

Remarks

You must apply the MenuItems method twice to return an item on a submenu. The following example sets the Checked property for the mySubMenuItem submenu item on the mySubMenu submenu.


MenuBars(xlModule).Menus("myMenu").MenuItems("mySubMenu") _
    .MenuItems("mySubMenuItem").Checked = True

See Also

Menus Method.

Example

This example adds a menu item to the Help menu on the active menu bar.


With ActiveMenuBar.Menus("Help")
    Set mi = .MenuItems.Add("&More Help", "my_Help_Macro")
End With

This example changes the Open command on the File menu to Open Workbook. The example makes this change to every menu bar in the product.


For Each mb In MenuBars
    mb.Menus("File").MenuItems(2).Caption = "&Open Workbook"
Next mb