Closing down Excel work books

  • Thread starter Thread starter peterspindrift
  • Start date Start date
P

peterspindrift

Is it possible to suppress the pop up when closing down excel that ask
'DO YOU WANT TO SAVE THE CHANGES YOU MADE
 
If you're talking about manually closing a workbook that has had changes
made then I don't think it is. With a macro you could do it either by
making Excel act as if no changes were made (ActiveWorkbook.Saved = True) or
by directly closing it (ActiveWorkbook.Close SaveChanges:=False).
 
To suppress the pop up, and save the workbook IF IT'S
BEEN CHANGED (saves automatically the changes, if any),
you can write the following lines in the code area of the
workbook:

Private Sub Workbook_BeforeClose(Cancel as Boolean)
If Me.Saved = False Then Me.Save
End Sub

To do that:
1.Open the Visual Basic Editor (ALT+f11)
2.In the Project explorer, select ThisWorkbook; now in
the window of the right, where it says General,
select "Workbook" ; and in Proyect select "BeforeClose"
3.Write between the first and the last line:
If Me.Saved = False Then Me.Save

4. Close the Visual Basic Editor
 

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