Close workbook without alerts

J

Jeff Wright

Hi,

I don't want users of my workbook to have the option of saving changes when
closing. I tried:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Application.DisplayAlerts = False
End Sub

.. . . but this doesn't work. How can I code my workbook to close with no
prompts to the user??

Thanks!!

Jeff
 
G

Guest

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

End Sub
 
N

Norman Jones

Hi Jeff,

Try:

'=============>>
Private Sub Workbook_BeforeSave( _
ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Cancel = True
MsgBox Prompt:="This workbook cannot be saved"
End Sub

'--------------->>
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Me.Saved = True
End Sub
'<<=============
 

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