100% eliminate the "Save before quitting?" message

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

Robert Nguyen

In addition to the Save line, include the following line:
Application.DisplayAlerts = False
 
M

Marvin Hlavac

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?
 
R

Robert Nguyen

Hi Marvin
Try put it before the save line
Another thing to try is use thisworkbook.save instead of
your save. Hope this helps.
 
R

Robert Nguyen

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
 
M

Marvin Hlavac

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?".
 

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