Disable Alert

  • Thread starter yourenotathomenow
  • Start date
Y

yourenotathomenow

I've put this in my 'This Workbook' space. But it doesn't seem to be
working. Any ideas?

Private Sub Workbook_BeforeClose(Cancel As Boolean)

'Disables 'Do you want to save changes?' Alert Before Close

Application.DisplayAlerts = False

End Sub
 
P

Per Jessen

Hi

What are you trying to do ?

If you want to close the workbook without saving the workbook and no
alerts, then use the below in your "Workbook_BeforeClose" event (You
don't have to turn off the alert):

Thisworkbook.Saved=True.

Hopes this heps.
 
Y

yourenotathomenow

Hi

What are you trying to do ?

If you want to close the workbook without saving the workbook and no
alerts, then use the below in your "Workbook_BeforeClose" event (You
don't have to turn off the alert):

Thisworkbook.Saved=True.

Hopes this heps.

---
Per







- Show quoted text -

Thanks. It worked. Any ideas why my first try didn't work?
 
H

Howard31

If you want to save the workbook then put the following code:
ThisWorkbook.Save

If you don't want to save then put the following:
ThisWorkbook.Saved = True
 
P

Per Jessen

Hi

Excel will always prompt the user to save an unsaved file before
closing it.

Another solution to close without saving:

ThisWorkbook.Close SaveChanges:=False

Regards,
Per
 
Y

yourenotathomenow

Hi

Excel will always prompt the user to save an unsaved file before
closing it.

Another solution to close without saving:

ThisWorkbook.Close SaveChanges:=False

Regards,
Per






- Show quoted text -

Thanks, All.
 

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