Using a macro to close Excel itself


Posted by Michelle on July 16, 2001 8:30 AM

I have about 20 macros that are scheduled to run daily. They do their thing, print the reports, close all active sheets, and then leave all those instances of Excel up on the computer. The first thing I do in the morning is just close those blank instances of Excel down. They aren't really hurting anything, but I'm sure there is danger in volume. If I ever get to go on vacation for a few weeks, I'd be worried that my less-than-new workhorse PC could withstand a few hundred instances of Excel up.

Do you guys know of any way I could have the macro close down not only the reports, but also Excel itself?

Thanks!

Posted by Damon Ostrander on July 16, 2001 8:59 AM

Hi Michelle,

Just use the Application object's Quit method to close each instance of Excel:

Application.Quit

You will also want to use the workbook object's Save method to save any changed workbooks before quitting:

ThisWorkbook.Save

Damon

Posted by JAF on July 16, 2001 9:00 AM

At the end of the macro, just add the line: Application.Quit to close Excel down.



Posted by Michelle on July 16, 2001 9:00 AM

Great - I'll try it. Thanks a bunch!!