Thread: Closing Excel
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default Closing Excel

"Sunil Jayakumar" <sunil.jayakumar[at]gmail.com wrote in message
...
I have an excel workbook with macros that calls macros in other workbooks,
and all this works well.

It executes the code, and closes the other workbooks fine, but I can't
figure out how to close the "host" workbook and exit excel completely,
rather than leaving an excel shell open.


Hi Sunil,

Application.Quit will close Excel and any workbooks that are open in it.
This must be the last line of code in your workbook. All VBA code in a
workbook stops running when that workbook is closed, so if you close the
workbook before trying to close Excel, it won't work. If you want to avoid
the prompt to save your workbook that Excel may display on closing, add the
line ThisWorkbook.Saved = True just before the Application.Quit line.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm