ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Close workbook without alerts (https://www.excelbanter.com/excel-programming/387883-close-workbook-without-alerts.html)

Jeff Wright[_2_]

Close workbook without alerts
 
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



Mike

Close workbook without alerts
 
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False

End Sub

"Jeff Wright" wrote:

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




Norman Jones

Close workbook without alerts
 


--
---
Regards,
Norman
Microsoft Excel MVP



"Jeff Wright" wrote in message
...
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




Norman Jones

Close workbook without alerts
 
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
'<<=============


---
Regards,
Norman



"Jeff Wright" wrote in message
...
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




Jeff Wright[_2_]

Close workbook without alerts
 
Norman,

This is great, and does exactly what I want it to do!

Thanks,


Jeff


"Norman Jones" wrote in message
...
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
'<<=============


---
Regards,
Norman



"Jeff Wright" wrote in message
...
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







All times are GMT +1. The time now is 10:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com