Closing down Excel work books

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
 
J

Jim Rech

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).
 
R

Rafa Marcenaro

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
 
Top