Write macro don't ask to save when exit excel  
Author Message
Mickman





PostPosted: Top

Excel Programming >> 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

Excel146