100% eliminate the "Save before quitting?" message

  • Thread starter Thread starter Marvin Hlavac
  • Start date Start date
M

Marvin Hlavac

Hi,

In my workbook I have:

ActiveWorkbook.Saved = True

and it works. However, there are two instances when it does not work and I
still get the "Save before quitting?".

First, when more then one workbook is open and I click on the "X" to close
all at once I still get the "Save before quitting?" and also if the workbook
is open and I try to restart or shut down the machine.

I'd like, if possible, never to get the "Save before quitting?".

Any help appreciated.
 
In addition to the Save line, include the following line:
Application.DisplayAlerts = False
 
Hi Robert

Thanks for your reply. It behaves exactly the same, perhaps I'm doing
something wrong. This is how the whole thing looks like now:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveWorkbook.Saved = True
Application.DisplayAlerts = False
End Sub

Is that correct?
 
Hi Marvin
Try put it before the save line
Another thing to try is use thisworkbook.save instead of
your save. Hope this helps.
 
Instead of ActiveWorkbook.Saved = True
try ThisWorkbook.Save

I don't know if it will make a difference but that's
what I use.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
ThisWorkbook.Save
End Sub
 
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
ThisWorkbook.Save
End Sub


My fault Robert, I didn't in my very first post say I just wanted the
workbook to close withour saving. What the above does is save. I just want
to close without having to click on the "No" in the "Save before quitting?".
 
Back
Top