Applies To
Application Object.
Description
Accessor. Returns an object that represents a single menu bar (a MenuBar object, Syntax 1) or a collection of the top-level menu bars (the MenuBars object, Syntax 2). Read-only.
Syntax 1
object.MenuBars(index)
Syntax 2
object.MenuBars
object
Optional. The Application object.
index
Required for Syntax 1. The name or number of the menu bar. Several predefined constants are available, as shown in the following table.
Constant
Description
xlWorksheet
Worksheet, macro sheet and dialog sheet.
xlChart
Chart
xlModule
Visual Basic module
xlNoDocuments
No documents open
xlInfo
Info Window
xlWorksheetShort
Short Worksheet menu (for Microsoft Excel version 3 compatibility)
xlChartShort
Short Chart menu (for Microsoft Excel version 3 compatibility)
xlWorksheet4
Old worksheet menu bar (for Microsoft Excel version 4 compatibility)
xlChart4
Old chart menu bar (for Microsoft Excel version 4 compatibility)
Example
This example resets all menu bars in Microsoft Excel.
For Each mb In MenuBars mb.Reset Next mb
This example adds a new menu to the module menu bar.
MenuBars(xlModule).Menus.Add Caption:="&More Help"