Custom Menu Commands Displayed in Incorrect Order (115697)



The information in this article applies to:

  • Microsoft Excel for Windows 5.0

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).

MORE INFORMATION

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.
  3. Choose the Insert button.

    A new menu bar is created (New Menu Bar1).
  4. In the Menus box, select (End of menu bar), and choose Insert.
  5. In the Caption box, type Test Menu and select (End of menu bar).
To insert the menu items:

  1. In the Menus Box, select Test Menu.
  2. In the Menu Items box, select (End of menu), and choose the Insert button.
  3. In the Caption box, type Constants, and under Menu Items, select (End of menu).
  4. 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:

  1. Under Menu Items, select Constants, and under Submenu Items, select (End of submenu).
  2. Choose Insert.
  3. In the Caption box, type Errors.
  4. Select "(End of submenu)".
  5. 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

  6. Under Menu Items, select Formulas, and under Submenu Items, select (End of submenu).
  7. Repeat steps 2-6 to add submenu items to the Formulas menu.
  8. Choose OK to close the Menu Editor.
To display the menus:

  1. On the module sheet, type the following:
          Sub MyMenu()
             MenuBars("New Menu Bar1").Activate
          End Sub
    						
  2. Choose Macro from the Tools menu.
  3. Select "MyMenu" from the list of macros, and choose Run.
The resulting menu items in the Select menu are: Formulas, <separator>, 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."

REFERENCES

"Visual Basic User's Guide," version 5.0, Chapter 12, "Menus and Toolbars"

For more information about Menu Editor command (Tools menu), choose the Search button in Help for Visual Basic and type:

menu bars


Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbProgramming KB115697