How can I close Excel with a macro ?

R

Roger Ottaway

I have Excel 2002 on Win XP. How can I close Excel with a macro.? In Access
I use a macro with Quit in it, this closes the database as well as Access.
Is there an equivalent in excel which will close the workbook and then Excel
itself ?



Thanks . Roger
 
G

Gord Dibben

Roger

Use this to close the workbook without saving

ThisWorkbook.Saved = True
Application.Quit

And this if you want to save it first

ThisWorkbook.Save
Application.Quit

If you want to suppress warnings preface wrap the code with

Application.DisplayAlerts = False

Gord Dibben XL2002
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top