Excel: OPEN and FILE.DELETE Functions Return Error

Last reviewed: October 31, 1994
Article ID: Q49273

SUMMARY

In Excel version 2.20, the OPEN and FILE.DELETE functions return an error if the filename is not found in the current directory. A dialog box does not appear as the documentation suggests on pages 217 and 254 of the "Microsoft Excel Functions and Macros" manual.

The following are three possible workarounds:

  1. Include the path in the OPEN or FILE.DELETE functions, as shown in the following example:

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

  2. Trap the error from the OPEN function in the following manner:

          =ERROR(FALSE)
          =IF(ISERROR(OPEN(file)),ALERT("Please locate: "&file,2)+OPEN?())
          =RETURN()
    

    Using this procedure opens the specified file if it resides in the current directory or, if the document can't be found, an Open Document dialog box appears.

  3. Trap the error from the FILE.DELETE function in the following manner:

          =ERROR(FALSE)
    

=IF(ISERROR(FILE.DELETE(file)),ALERT("locate:"&file,2)+FILE.DELETE?())
      =RETURN()

   This procedure deletes the specified file if it resides in the
   current directory or, if the document can't be found, a Delete
   Document dialog box appears.

Note: The OPEN? and FILE.DELETE? functions call the Open Document and Delete Document dialog boxes as if Open or Delete were selected from the File menu.


KBCategory: kbother
KBSubcategory:

Additional reference words: 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.