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

ID: Q77981


The information in this article applies to:


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]

<Command_name>=<menu_#>,<menu_name>,<command>,<macro_name>, <position>,<blank>,<status_msg>,<help>

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

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

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

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

<Macro_name> 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

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

<Blank> should always be left blank.

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

<help> 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 "T" in Test will be underlined, denoting that "T" 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.


REFERENCES

"Online Help," version 5.0
"User's Guide 2," version 4.0, pages 286-290
"Function Reference," version 4.0, pages 8-9
"User's Guide," version 3.0, pages 646-650
"Function Reference," version 3.0, pages 5-6
EXCEL.INI. Excel for Windows version 3.0, WINDOWS directory
EXCEL.INF. Excel for Windows version 3.0, Excel 3.0 Setup Disk

Additional query words: 3.0 4.0 5.0 solver


Keywords          : 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: March 22, 1999