Macro closing Excel file without saving changes

W

windsurferLA

The VBA code

If Dir("opening test2.xls") <> "" Then Kill "opening test2.xls"

closes the file, but only after a dialog box response approves closing
without saving. How does one close the workbook without the need for
approving the closing in a dialog box?
 
D

Dave Peterson

Kill deletes the file. It doesn't close the file.

If you want to close a workbook without saving, you could use:

workbooks("opening test2.xls").close savechanges:=false
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top