ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Write macro don't ask to save when exit excel (https://www.excelbanter.com/excel-programming/357408-write-macro-dont-ask-save-when-exit-excel.html)

Rui Álvares

Write macro don't ask to save when exit excel
 
Hi all

I need to write a macro that when I exit Excel (or close document) by
clickin in the Red Cross of Excel Officce XP) domn't ask to save a document.
I've already tested some parts of code as show below:

strName = Activeworkbook.name
workbooks(strName).Close SaveChanges:=False

ThisWorkbook.Saved = True
Application.Quit

Application.DisplayAlerts=False

Application.EnableEvents = False

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

but all of them don't worked like I want.
Anybody knows??

Thanks in advance

Rui Ávares




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

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