MrExcel Publishing
Your One Stop for Excel Tips & Solutions

closing Excel


Posted by steve on January 08, 2002 1:23 AM

Thanks for the replies yesterday. Yes Application.Quit does close excel. My code was

ActiveWorkbook.Close SaveChanges = false
Application.Quit

That didn't work.

How can I close Excel without saving any changes or be prompted to?

THANKS


Posted by Dank on January 08, 2002 1:40 AM

Hello Steve,

I still don't know why your code won't work. It works fine on my machine. Are you using XL 2000 or XP?

Your code doesn't allow for more than one workbook being open so you'll still get a prompt if there is more than one workbook open which has been changed. You might want to try something like this:-

Sub CloseExcelv2()
Application.DisplayAlerts = False 'Override Excel messages
Application.Quit
End Sub

HTH,
Daniel.


Posted by Roderigo on January 08, 2002 1:53 AM


Application.DisplayAlerts = False
Application.Quit


Posted by steve on January 08, 2002 1:57 AM

Thanks for your help. This works fine.


Posted by Roderigo on January 08, 2002 2:08 AM

Warning ....


When using Application.Quit, if you have add-ins that run Auto-Close macros, it might cause Excel to crash. Also don't put any code after Application.Quit - it won't be run in Excel 97/2000.