Microsoft KB Archive/74342

{| = Excel: Changing the Default Directory =
 * width="100%"|

Last reviewed: August 25, 1995

Article ID: Q74342 The information in this article applies to:
 * Microsoft Excel for Windows, versions 2.x, 3.x, 4.x

SUMMARY
In Microsoft Excel, there are various methods to change the default directory in which Microsoft Excel starts. Microsoft Excel will normally start up with the directory to which you installed Microsoft Excel as the active directory, but you may want to change this default to a specified directory. You can check the current default directory by choosing Open from the File menu after starting the Microsoft Excel program. The current directory is listed after &quot;Directory is...&quot;

Microsoft Excel Version 3.0
Modify Program Icon Properties:

 Verify that the directory containing EXCEL.EXE is in the path statement of your AUTOEXEC.BAT file. From the Program Manager, select the Microsoft Excel icon and choose Properties from the File menu.  Type the path of the desired directory in the Command Line text box, followed by &quot;\excel.exe&quot; (without the quotation marks). For example, type the following: c:\user\excel.exe  The error message &quot;The specified path is invalid&quot; will appear. Choose OK to bypass this message.

Microsoft Excel will now start with the specified directory as the default drive and directory. This method changes the icon from the standard Microsoft Excel icon to a MS-DOS icon. To correct this, do the following:
 * 1) Select the icon once again in the Program Manager. From the File menu, choose Properties.
 * 2) Choose the Change Icon button.
 * 3) Type the correct path for the EXCEL.EXE file (for example, c:\excel\excel.exe) and press the ENTER key.

You will see the message &quot;The specified path is invalid&quot; once again. However, you can ignore it at this point and everything will still work properly. If you are using Windows 3.1, you can change the Working Directory from within Program Manager. From the File menu, choose Properties and type the path in the Working Directory field box.

Microsoft Excel Versions 3.0 and 4.0 Only
Create An Add-In:

A1: DEFAULT_DIR A2: =DIRECTORY(&quot;C:\USER&quot;) A3: =RETURN Enter the above macro into a macro sheet. Select cell A1. Define this macro as an Auto_Open macro by choosing Define Name from the Formula menu, entering &quot;auto_open&quot; (without the quotation marks) in the Name box, and selecting the Command button. Choose OK. Save the macro as an add-in macro in the XLSTART directory by choosing Save As from the File menu, choosing Options, and selecting Add-In from the list. Choose OK. For the filename, enter the path to the XLSTART directory, followed by the filename (for example, c:\excel\xlstart\defltdir.xla). Documents that are saved in the XLSTART directory are automatically opened when the Microsoft Excel program is started. Because this macro sheet is saved as an add-in macro, it will open as hidden. You are unable to view it, even by choosing the Window Unhide command. However, the macro will run because it has been saved as an Auto_Open macro.

Microsoft Excel Versions 2.x, 3.x, and 4.x
Create an Auto_Open Macro:

 Open a new macro sheet. Choose Save As from the File menu and enter &quot;c:\changedi.xlm&quot; (or any valid path and filename, without the quotation marks) in the File Name box. Choose OK.  Enter the following macro into the macro sheet: A1: Auto_Open A2: =DIRECTORY(&quot;C:\USER&quot;) A3: =NEW A4: =RETURN The =DIRECTORY statement will set the current drive to the path described in the pathname. The =NEW command will open up a blank worksheet.   Define the macro as an Auto_Open macro by doing the following: a. Select cell A1. b. From the Formula menu, choose Define Name. c. Choose the Command button. d. Choose OK. </li>  In Notepad (or another text editor), open the EXCEL.INI file (version 3.0) or the EXCEL4.INI file (version 4.0). This file is located in the WINDOWS directory. Scroll down to the [Microsoft Excel] heading and add the following line below the heading: open=c:\changedr.xlm </li></ol>

This causes CHANGEDR.XLM to open every time Microsoft Excel is started. Use /p Startup Switch:

You can specify a default working directory by using the &quot;/p&quot; startup switch. For more information, refer to the &quot;User's Guide.&quot;

Microsoft Excel Version 4.x Only
You can add an OPEN= statement in the [Microsoft Excel] section of your EXCEL4.INI file and use the /p option. This option specifies a directory to be used as the default directory from which documents are opened and to which documents are saved. Enter this option to the right of the equal sign in the OPEN= statement.

Microsoft Excel Version 4.0a Only
You can add the line &quot;OpenDir= &quot; to the EXCEL4.INI to set the working directory. This option overrides the icon properties working directory information and command line switches.

Microsoft Excel Version 5.0
For information about changing the working directory in Microsoft Excel version 5.0, please see the following article in the Microsoft Knowledge Base:

ARTICLE-ID: Q110209 TITLE    : XL5: Hierarchy of Methods to Change the Working Directory

Microsoft Excel Version 7.0
For information about setting the default file location in Microsoft Excel version 7.0, please see the following article in the Microsoft Knowledge Base:

ARTICLE-ID: Q135474 TITLE    : XL7: Starting Microsoft Excel with a Different Working Folder