ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Closing Excel (https://www.excelbanter.com/excel-programming/334404-closing-excel.html)

Sunil Jayakumar

Closing Excel
 
Hi,

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.

Any ideas appreciated.

Warm regards

Sunil Jayakumar



STEVE BELL

Closing Excel
 
This will close the application in Excel 2000.
[you may want to save your workbook first]
[or you can set the workbook
ThisWorkbook.Save = True
this is supposed to make Excel think the workbook is already saved]

Application.Quit


--
steveB

Remove "AYN" from email to respond
"Sunil Jayakumar" <sunil.jayakumar[at]gmail.com wrote in message
...
Hi,

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.

Any ideas appreciated.

Warm regards

Sunil Jayakumar




Rob Bovey

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




All times are GMT +1. The time now is 09:25 PM.

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