Excel: Changing the Default Directory

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 "Directory is..."

Microsoft Excel Version 3.0

Modify Program Icon Properties:

  1. Verify that the directory containing EXCEL.EXE is in the path statement of your AUTOEXEC.BAT file.

  2. From the Program Manager, select the Microsoft Excel icon and choose Properties from the File menu.

  3. Type the path of the desired directory in the Command Line text box, followed by "\excel.exe" (without the quotation marks).

    For example, type the following:

          c:\user\excel.exe
    

  4. The error message "The specified path is invalid" 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 "The specified path is invalid" 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("C:\USER")
   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 "auto_open" (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:

    1. Open a new macro sheet. Choose Save As from the File menu and enter "c:\changedi.xlm" (or any valid path and filename, without the quotation marks) in the File Name box. Choose OK.

    2. Enter the following macro into the macro sheet:

            A1: Auto_Open
            A2: =DIRECTORY("C:\USER")
            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.

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

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

    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 "/p" startup switch. For more information, refer to the "User's Guide."

    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 "OpenDir=<path>" 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
    
    

    REFERENCES

    "Microsoft Windows User's Guide," version 3.1, pages 79-81 "Microsoft Windows User's Guide," version 3.0, pages 89-91 "Microsoft Excel User's Guide 1," version 4.0, pages 79-80, 292 "Microsoft Excel User's Guide," version 3.0, pages 553, 651 "Microsoft Excel Reference Guide," version 2.1, pages 209-211 "Microsoft Excel Functions and Macros," version 2.1, pages 270, 353


  • KBCategory: kbusage
    KBSubcategory: xlwin

    Additional reference words: 2.00 2.01 2.10 2.20 2.21 3.00 4.00 4.00a


    THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

    Last reviewed: August 25, 1995
    © 1998 Microsoft Corporation. All rights reserved. Terms of Use.