Microsoft KB Archive/49273

{| = Excel: OPEN and FILE.DELETE Functions Return Error =
 * width="100%"|

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 &quot;Microsoft Excel Functions and Macros&quot; manual.

The following are three possible workarounds:

  Include the path in the OPEN or FILE.DELETE functions, as shown in the following example: =OPEN(&quot;Hard Disk:Folder:Worksheet1&quot;)   Trap the error from the OPEN function in the following manner: =ERROR(FALSE) =IF(ISERROR(OPEN(file)),ALERT(&quot;Please locate: &quot;&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.   Trap the error from the FILE.DELETE function in the following manner: =ERROR(FALSE) 

=IF(ISERROR(FILE.DELETE(file)),ALERT(&quot;locate:&quot;&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.
 * }