Programatically close a file without saving

  • Thread starter Thread starter vvaidya
  • Start date Start date
V

vvaidya

Hello:
I need to be able to close a file programmatically, but when I try to
do so the Excel message: "Do you want to save the changes that you made
to ---" With the choices "Yes", "No" and "Cancel" comes off & I would
like to close the file without saving it.
I would appreciate help wit the above.

TIA
Vinay
 
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
End Sub

Gord Dibben Excel MVP
 
You could also use one of these:

ThisWorkbook.Close SaveChanges:=False

or

Application.DisplayAlerts = False

Regards,
KL
 

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

Back
Top