Excel: Opening Documents Not in Current Folder from Macro

Last reviewed: October 31, 1994
Article ID: Q47586

SUMMARY

OPEN() is a macro function to open Excel files. OPEN() defaults to opening files within the current folder.

To open a file outside of the current folder, you can use one of the two following methods:

  1. Include the directory path in the Open statement.

  2. Precede the OPEN() function with the DIRECTORY() function.

MORE INFORMATION

For example, if you want to open a file called "Worksheet1" in the folder "Expenses" on the hard drive "Hard Disk", the OPEN() function would be as follows:

   =OPEN("Hard Disk:Expenses:Worksheet1")

In Excel 1.50 and later, you can use the DIRECTORY() function to achieve the same results, as follows:

   =DIRECTORY("Hard Disk:Expenses")
   =OPEN("Worksheet1")

The DIRECTORY() function in Excel 1.50 and later changes the current folder.

If you want to open a file in another folder but not change the current folder, use the first method. The second method should be used if you want to change the current folder.

For more information, see page 213 for DIRECTORY() and page 254 for OPEN() in the "Microsoft Excel Functions and Macros" manual for version 2.20, or page 224 for DIRECTORY() and page 250 for OPEN() in the "Microsoft Excel Arrays, Functions, and Macros" manual for version 1.50.


KBCategory: kbother
KBSubcategory:

Additional reference words: 1.00 1.03 1.04 1.06 1.50 2.20


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: October 31, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.