Microsoft KB Archive/77981

{|
 * width="100%"|

Using the [Init Commands] Section of the EXCEL.INI File

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, versions 3.0, 4.0, 5.0

-

SUMMARY
The [Init Commands] section in the EXCEL.INI file (in version 5.0 the EXCEL5.INI file) allow custom commands to be added to the Microsoft Excel default menus without having to execute a macro to do so.

MORE INFORMATION
The general syntax for an entry in the [Init Commands] section appears as follows:

Syntax for [Init Commands]
=,, ,,, ,,

 is the name you will use to distinguish one command from another. The command_name is required, but is essentially ignored by Excel and has no effect on the command or how it will appear in the menu.

 is the Excel default menu bar number in which you want the command to be available. A number 1 through 6 is required. If you want a command to be available in all six default menus, six separate [Init Command] entries are required.

 is the name, or number, of the menu under which you want the command to appear. Numbering the menus begins on the left, starting with 1.

 is the actual command that will appear under the specified menu. As with all custom menu commands an ampersand (&) can be placed in front of the letter you want to make a menu accelerator key. This item is required.

 is the name of the macro you want to run when the custom command is selected. Unless there is no doubt that the macro or add-in will be open, the drive and path to the macro should be specified. When giving the drive and path, the macro_name parameter should take the following form:

'C:\EXCEL\DATA\MACRO1.XLM'!TEST

(Note the single quotation marks surrounding the drive, path, and sheet name.) This item is required.

In version 5.0 when you refer to the macro file name, the name of the workbook must be in brackets, with the sheet name following.

'C:\EXCEL\DATA\[BOOK1.XLS]MACRO1'!TEST

 can be either the number representing the relative position the command should take in the command list or the name of the command above which you want your command to appear. Numbering begins with 1, starting from the top.

Command names should be spelled just as they appear on the screen, including ellipses (...) if necessary. This item is optional, and entries without this parameter will appear at the bottom of the specified menu's command list.

 should always be left blank.

 is optional. The text you want to appear in the status bar when this command is selected should be placed here.

specifies the help file and topic that should appear if the user presses F1 while the command is highlighted in the menu.

Sample Entry
The following is an example:

  Test=1,File,&Test,'C:\EXCEL\MACRO.XLM'!TESTMACRO,1,,Load Test Macro,TESTHELP.HLP!10

The above sample entry will:


 * 1) Create a menu item, Test, which will appear as the first item under the File menu. It will only appear on Menu Bar 1 (Full menus for worksheets and macro sheets).
 * 2) The first &quot;T&quot; in Test will be underlined, denoting that &quot;T&quot; is an accelerator key.
 * 3) The command will open the MACRO.XLM macro sheet from the C:\EXCEL directory and run the macro named TESTMACRO.
 * 4) If F1 is pressed when the Test command is chosen, Windows Help will open the TESTHELP.HLP file and display topic number 10 in that file.

Note: Although the examples in this article appear on more than one line, entries in the EXCEL.INI (EXCEL5.INI) file should appear on a single line. The lines are word wrapped here for convenience.

The EXCEL.INF cannot be modified to include custom [Init Commands] entries.