XL97: Using the MenuBars Method in Microsoft Excel 97ID: Q156880
|
In Microsoft Excel versions 5.0 and 7.0, you can use the MenuBars method in
a Visual Basic for Applications macro to display different menu bars in
Microsoft Excel. In Microsoft Excel 97, the MenuBars method is replaced by
the CommandBars method.
However, to provide backward compatibility, Microsoft Excel 97 still
supports the MenuBars method. Note that the MenuBars method works
differently in Microsoft Excel 97 than it does in earlier versions of
Microsoft Excel.
This article explains how to use the MenuBars method in Microsoft Excel 97.
MenuBars(<xlConstant>).Activate
where <xlConstant> is a variable.
Value in Value in
97 command bar name 97 Version Earlier Versions
----------------------------------------------------------
Worksheet Menu Bar xlWorksheet xlWorksheet4
Chart Menu Bar xlChart xlChart4
Worksheet Menu Bar xlWorksheet xlNoDocuments
Worksheet Menu Bar xlWorksheet xlInfo
Worksheet Menu Bar xlWorksheet xlWorksheetShort
Chart Menu Bar xlChart xlChartShort
Worksheet Menu Bar xlWorksheet xlWorksheet
Chart Menu Bar xlChart xlChart
Menu in Visual Basic
Editor <None> xlModule
Example:
MenuBars(xlWorksheet4).Activate
Microsoft Excel 97 displays the "Worksheet Menu Bar" command bar, because
the xlWorksheet4 value translates to "Worksheet Menu Bar" in Microsoft
Excel 97.
CommandBars("Worksheet Menu Bar").Visible = True
NOTE: The CommandBars command does not use the value listed in the table.
Instead, the command uses the name of the command bar that you want to
display.
Application.VBE.MainWindow.Visible = True
MenuBars(<xlConstant>).Activate
where <xlConstant> is a variable.
Menu bar Value
----------------------------------------------------------
Worksheet (Microsoft Excel 4.0) xlWorksheet4
Chart (Microsoft Excel 4.0) xlChart4
No Documents Open xlNoDocuments
Info xlInfo
Worksheet (Microsoft Excel 4.0, short) xlWorksheetShort
Chart (Microsoft Excel 4.0, short) xlChartShort
Worksheet xlWorksheet
Chart xlChart
Visual Basic Module xlModule
Example:
MenuBars(xlWorksheet4).Activate
For more information about using the MenuBars method in Microsoft Excel 97, activate a Visual Basic module, type the following text
menubarsselect the word, and press F1 to display the "Hidden Properties and Methods" help topic.
Additional query words: XL97 8.0
Keywords : kbinterop kbdta KbVBA xlvbmigrate
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: July 2, 1999