Microsoft KB Archive/115697

= Custom Menu Commands Displayed in Incorrect Order =

Article ID: 115697

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 5.0 Standard Edition

-



This article was previously published under Q115697



SYMPTOMS
When you use the Menu Editor tool to customize your menus, adjacent menus that contain submenu items may not be displayed in the order in which they were created.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel for Windows version 5.0c.



WORKAROUND
To work around this problem, do either of the following:


 * Put a separator ("-") between the menu commands that contain submenu items, or place a menu item that doesn't have submenu items between the menu commands that do contain submenu items. -or-


 * Use a Visual Basic, Applications Edition, procedure to create the new menus (rather than using the Menu Editor).



Steps to Reproduce the Problem
To set up the custom menus:


 * 1) In a new Visual Basic module, choose Menu Editor from the Tools menu.
 * 2) In the Menu Bars box, choose any menu bar from the list.

You should see the name of the menu bar repeated in the Caption box.
 * 1) Choose the Insert button.

A new menu bar is created (New Menu Bar1).
 * 1) In the Menus box, select (End of menu bar), and choose Insert.
 * 2) In the Caption box, type Test Menu and select (End of menu bar).

To insert the menu items:

 In the Menus Box, select Test Menu. In the Menu Items box, select (End of menu), and choose the Insert button. In the Caption box, type Constants, and under Menu Items, select (End of menu). Repeat steps 2 through 3 to create the following additional menu items (substitute the following items for the word "Constants" in step 3):

Formulas

-

Hello



To insert the submenu items:

 Under Menu Items, select Constants, and under Submenu Items, select (End of submenu).</li> Choose Insert.</li> In the Caption box, type Errors .</li> Select "(End of submenu)".</li> Repeat steps 2 through 4 to create the following additional submenu items (substitute the following items for the word "Errors" in step 3):

Text

Number

</li> Under Menu Items, select Formulas, and under Submenu Items, select (End of submenu).</li> Repeat steps 2-6 to add submenu items to the Formulas menu.</li> Choose OK to close the Menu Editor.</li></ol>

To display the menus:

  On the module sheet, type the following: Sub MyMenu MenuBars("New Menu Bar1").Activate End Sub </li> Choose Macro from the Tools menu.</li> Select "MyMenu" from the list of macros, and choose Run.</li></ol>

The resulting menu items in the Select menu are: Formulas,, Hello, Constants. Constants should be first with Formulas directly beneath it.

To reset the menu bar to the default module menu bar, create and run the following macro: Sub newmenu MenuBars(xlModule).Activate End Sub Microsoft provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose. Note that a line that is preceded by an apostrophe introduces a comment in the code--comments are provided to explain what the code is doing at a particular point in the procedure. Note also that an underscore character (_) indicates that code continues from one line to the next. You can type lines that contain this character as one logical line or you can divide the lines of code and include the line- continuation character. For more information about Visual Basic for Applications programming style, see the "Programming Style in This Manual" section in the "Document Conventions" section of the "Visual Basic User's Guide."

<div class="references_section">