ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Exit Workbook (https://www.excelbanter.com/excel-programming/337478-exit-workbook.html)

Mark

Exit Workbook
 
When i exit excel using the close 'X' top right of my page - it keeps
prompting me to save changes.I dont want it to save changes and just close.I
either want to get rid of the 'X' or use some code so it doesnt prompt me to
save.I am currently using this code but its not working for some reason.Any
help out there please...

Private Sub Workbook_Close()
Application.DisplayAlerts = False
Workbook.Close savechanges:=False
End Sub

Thks in adavnce
Mark

sebastienm

Exit Workbook
 
Hi,
Try:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Me.Saved = True
End Sub

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Mark" wrote:

When i exit excel using the close 'X' top right of my page - it keeps
prompting me to save changes.I dont want it to save changes and just close.I
either want to get rid of the 'X' or use some code so it doesnt prompt me to
save.I am currently using this code but its not working for some reason.Any
help out there please...

Private Sub Workbook_Close()
Application.DisplayAlerts = False
Workbook.Close savechanges:=False
End Sub

Thks in adavnce
Mark


Norman Jones

Exit Workbook
 
Hi Mark,

Private Sub Workbook_Close()
Application.DisplayAlerts = False
Workbook.Close savechanges:=False
End Sub


Try, instead:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Me.Saved = True
End Sub


BTW, there is no Workbook_Close event.



---
Regards,
Norman



"Mark" wrote in message
...
When i exit excel using the close 'X' top right of my page - it keeps
prompting me to save changes.I dont want it to save changes and just
close.I
either want to get rid of the 'X' or use some code so it doesnt prompt me
to
save.I am currently using this code but its not working for some
reason.Any
help out there please...

Private Sub Workbook_Close()
Application.DisplayAlerts = False
Workbook.Close savechanges:=False
End Sub

Thks in adavnce
Mark





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

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