Defining Custom Menus and Custom Commands

You can use the Init Menus and Init Commands subkeys to define custom menus and commands. These custom menus and commands appear every time you start Microsoft Excel and enable you to load add-ins or standard macro sheets after you choose the custom command.

Note

The Add-In Manager (the Add-Ins command on the Tools menu) reads and writes entries in both the Init Menus and Init Commands subkeys.

The Init Commands Subkey

The syntax for Init Commands subkey entries is as follows:

Entry        Value
<Keyword>    <menu_bar_num>,<menu_name>,<command_name>,<macro>,
<command_position>,<macro_key>,<status_text>,<help_reference>

Argument

Description

<keyword>

A unique keyword, such as Scenario, that Microsoft Windows uses to identify commands added by an INI file.

<menu_bar_num>

The number of the built-in menu bar to which you want to add the command.

<menu_name>

The name of the new menu.

<command_name>

The name of the new command.

<macro>

A reference to a macro on an add-in workbook. Choosing the command opens the add-in and runs the specified macro.

<command_position>

The position of the command on the menu. This may be the name of the command after which you want to place the new command or a number indicating the command's position on the menu. If omitted, the command appears at the end of the menu.

<macro_key>

The key assigned to the macro, if any.

<status_text>

A message to be displayed in the status bar when the command is selected.

<help_reference>

The file name and topic number for a custom Help topic relating to the command.


The following example shows how an Init Commands entry specifies two commands to be added to built-in menu bar number 1.

Entry        Value
Views        1, Window, &View...,'C:\EXCEL\LIBRARY\VIEWS.XLA'!STUB,-,,
Show or define a named view,EXCELHLP.HLP!1730 Solver 1, Formula, Sol&ver...,'C:\EXCEL\LIBRARY\SOLVER\SOLVER.XLA'!STUB
,,,Find solution to worksheet model,EXCELHLP.HLP!1830

The Init Menus Subkey

The syntax for Init Menus subkey entries is as follows:

Entry        Value
<Keyword>    <menu_bar_num>,<menu_name>,<menu_position>

Argument

Description

<keyword>

A unique keyword, such as Custom1, that Microsoft Windows uses to identify menus added by an Init Menus registry entry.

<menu_bar_num>

The number of the built-in menu bar to which you want to add the menu or command.

<menu_name>

The name of the new menu.

<menu_position>

The position of the new menu on the menu bar. This may be the name of the menu after which you want to place the new menu or a number indicating the menu's position from the left of the menu bar. If there is a menu_parent, then menu_position is the position of the new menu on the menu_parent.

<menu_parent>

Optional. If defining a submenu, this is the menu name or number on the menu bar that will contain this new submenu.

<keyword>

A unique keyword, such as Custom1, that Microsoft Windows uses to identify menus added by an Init Menus registry entry.

<menu_bar_num>

The number of the built-in menu bar to which you want to add the menu or command.

<menu_name>

The name of the new menu.

<menu_position>

The position of the new menu on the menu bar. This may be the name of the menu after which you want to place the new menu or a number indicating the menu's position from the left of the menu bar. If there is a menu_parent, then menu_position is the position of the new menu on the menu_parent.

<menu_parent>

Optional. If defining a submenu, this is the menu name or number on the menu bar that will contain this new submenu.


Note

Microsoft Excel doesn't allow more than one new level of submenus.

The following example shows how an Init Menus entry specifies a custom menu to be added to the right of the Window menu.

Entry        Value
Custom1        1,Work,Window