Command-line switches for Excel
This article shows you how to customize the way that Microsoft Office Excel starts by adding switches and parameters to the startup command. For example, you can prevent the startup screen from appearing when you start Office Excel, or you can have Excel open a specific file when it starts.
Command line switches are also called command-line options, and sometimes you can use a parameter without a switch.
If you want to use a switch and any associated parameters just one time, you can type the command in the Run dialog box (Start menu) in Microsoft Windows. If you want to use the same switch and associated parameters many times, you can create a desktop shortcut that always starts the program by using the same switch and parameters. This article discusses how to do both, and contains a table that lists all of the switches and parameters that are available in Office Excel.In this article
Introducing commands, switches, and parameters
Use a switch once by adding it to the Run command
Make a switch available for reuse by creating a shortcut
Available switches and parameters
Introducing commands, switches, and parameters
Each time that you start Excel by clicking the Excel program icon or the program name on the Start menu, you are actually running the Excel.exe command, although you do not usually type the command or even see it.
You can change certain aspects of how the program starts by adding subcommands called switches to the Excel.exe command. A switch appears as a space after the main command, followed by a slash mark (/) and the name of the switch. The switch is sometimes followed by another space and then one or more specific instructions called parameters, which give the program further information about how to execute the Excel.exe command. For example, the following command instructs Excel to start and then open the specified file as read-only:
excel.exe /r "c:\My Folder\book1.xlsx"
In this example, the switch is /r, and the parameter is "c:\My Folder\book1.xlsx".
Use a switch once by adding it to the Run command
- In Microsoft Windows XP, click
Start, and then clickRun.In Microsoft Windows Vista, click the
Startbutton
, and then click Run. - In the
Rundialog box, type excel.exe, or clickBrowseto locate it. - Type a space, and then type the switch and any parameters. For example, to start Excel without displaying the startup screen and without opening a blank workbook, you would type:
excel.exe /e
The next time that you start Excel, the program will start according to its defaults (without making use of the switch that you just provided). To make your customized startup available for repeated uses, see the following section.
Notes:
- Switches and parameters are not case-sensitive. For example, /R is the same as /r.
- Remember to include one blank space before the switch and one before each parameter.
Make a switch available for reuse by creating a shortcut
First, verify the location of the Excel.exe file on your computer. If you accepted the default folder locations when you installed Excel, the Excel.exe file is probably located at:
- C:\Program Files\Microsoft Office\Office12\Excel.exe
If you do not find the Excel.exe file at that location, search for the file and make a note of the full path.
- Right-click the Windows desktop, point to
New, and then clickShortcuton the shortcut menu. - In the
Create Shortcut Wizard, in theType the location of the itembox, type a quotation mark ("), enter the full path for the Excel.exe file (including the file name), and then type a quotation mark. (Alternatively, clickBrowseto locate and select the file. In this case, the quotation marks are added automatically.) - Following the closing quotation mark, type a space, and then type the switch and any parameters. If the parameter is a path to a location on your computer, and the path contains a space, it also must be enclosed in quotation marks. For example:
"c:\program files\Microsoft Office\office12\excel.exe" /r "c:\My Folder\book1.xlsx" - Click
Next. - In the
Type a name for this shortcutbox, type a name for the shortcut, and then clickFinish.The wizard creates the shortcut and places it on the desktop.
- Whenever you want to start Excel in this particular customized way, double-click the shortcut.
Tip To add the desktop shortcut to the Windows
Startmenu, right-click the shortcut, and then clickPin to Start menuon the shortcut menu.
You can create a variety of shortcuts, each of which applies different switches and parameters to the program at startup.
Notes:
- Switches and parameters are not case-sensitive. For example, /R functions the same as /r.
- Remember to include one blank space before the switch and one before each parameter.
Available switches and parameters
The following table lists all of the switches and parameters that are available in Office Excel.
| Switch and parameter | Description |
|---|---|
| workbook path | file name
This parameter does not require a switch. | Starts Excel and opens the specified file. When you type the path as a URL, quotation marks are not necessary.
Example
or
|
| /r workbook path | file name | Opens a specific workbook as read-only. When you type the path as a URL, quotation marks are not necessary.
Example
or
|
| /t workbook path | file name | Starts Excel and opens the specified file as a template. When you type the path as a URL, quotation marks are not necessary.
Example
or
|
| /n workbook path | file name | Like /t, starts Excel and opens the specified file as a template. When you type the path as a URL, quotation marks are not necessary.
Example
or
|
| /e or /embed | Prevents the Excel startup screen from appearing and a new blank workbook from opening.
Example
|
| /p workbook path | Specifies a folder as the active working folder (for example, the folder that is pointed to in the Save As dialog box).
Example
|
| /s or /safemode |
Forces Excel to bypass all files that are stored in startup directories, such as the default XLStart folder located in the directory where Excel or the Microsoft Office system is installed. Example
|
| /m | Creates a new workbook that contains a single XLM macro sheet.
Example
|
| /a progID | Starts Excel and loads the Automation Addin that is specified by the progID of the add-in.
Example
|
![]()