Microsoft Knowledge Base

XL: Visual Basic Module to Display Delete File Dialog

Last reviewed: May 30, 1997
Article ID: Q120295
The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Excel for the Macintosh, version 5.0
  • Microsoft Excel 97 for Windows

SUMMARY

Microsoft Excel versions earlier than 5.0 have a Delete File command on the File menu. This command displays a dialog box that allows you to delete a file by selecting it from a list of files. Although this command is unavailable by design of Microsoft Excel versions 5.x and 7.0, in Microsoft Excel 5.0 and 7.x you can delete files from the Find File utility. You can also create a Visual Basic, Applications Edition, procedure to delete files directly from Microsoft Excel.

MORE INFORMATION

Sample Visual Basic Procedure to Delete Files

Microsoft provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.

The following macro displays the Microsoft Excel File Delete dialog box.

     Sub DeleteFile()
         'Displays the File Delete dialog
         Application.Dialogs(xlDialogFileDelete).Show
     End Sub

To make this procedure available whenever Microsoft Excel is running, you can assign the procedure to a menu command or a toolbar button. Note also, that you may want to place this procedure in the PERSONAL.XLS file so that it will always be available.

NOTE: Do NOT delete a file using the File Delete dialog box while the file is open. Although the dialog box will allow you to do this, you will not be able to save the open file if it has been deleted.

For more information about the PERSONAL.XLS file, see pages 22-23 of the "Visual Basic User's Guide."

For more information about using the Menu Editor, see pages 243-247 of the "Visual Basic User's Guide."

Or, click Answer Wizard on the Help menu and type in either "PERSONAL.XLS" or "Menu Editor" (without the quotes). Then, click Search.


Additional query words: 5.00 5.00c 7.00 97 howto
Keywords : kbcode
Version : 5.00 5.00c 7.00 | 5.00
Platform : MACINTOSH WINDOWS


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: May 30, 1997
©1997 Microsoft Corporation. All rights reserved. Legal Notices.