Applies To
Menus Collection.
Description
Adds a new menu. Can also be used to restore a built-in menu in Microsoft Excel that has been deleted. Returns a Menu object.
Syntax
object.Add(caption, before, restore)
object
Required. The Menus object.
caption
Required. The text of the menu (sets the initial value of the Caption property for the new menu). Use an ampersand (&) before the command underline.
before
Optional. Specifies the menu before which the new menu will be added. Can be either a number (one to insert at the beginning of the menu bar, for example) or a caption of another, existing menu (in the language of the macro, without the ampersand), or a reference to the menu. If this argument is omitted, the new menu is added to the left of the Window menu.
restore
Optional. If True, Microsoft Excel will restore the previously deleted built-in menu named caption. If False or omitted, Microsoft Excel will add a new menu. The restored menu is placed at the end of the menu bar unless you use the before argument to specify the location.
Remarks
On the Apple Macintosh, this method returns an error if there is not enough room to create the new menu. You should always check the return value to ensure that the new menu was added successfully.
In Windows, the menu bar will wrap if necessary to fit the new menu.
You cannot create a new shortcut menu; you can only modify a built-in shortcut menu.
Example
This example adds a new menu to the worksheet menu bar.
MenuBars(xlWorksheet).Menus.Add caption:="More Help"