ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Close Excel with a Macro (https://www.excelbanter.com/excel-discussion-misc-queries/239191-close-excel-macro.html)

JHB

Close Excel with a Macro
 
Sometimes the help files are useful, and sometimes not! In this case
they are not.

I want to shut down not only the spreadsheet but also the Excel
application with a macro. Its one of those things that should be
simple, but somehow I get tangled up with it, since shutting the
spreadsheet down also shuts down the macros, which means that Excel
doesn't get closed!

Suggestions for code would be appreciated by this neophyte!

Regards

John Baker

Dave Peterson

Close Excel with a Macro
 
Look at
Application.Quit
in VBA's help.

But this has never seemed like a very good idea to me.

If I have multiple workbooks open and you quit excel, will you close those
workbooks?

How will you (the author of the code) know if I wanted to save a file, saveas a
new name or just close without saving?

You could have many users ticked off when they run your code.

======
On the other hand, if you're controlling your own instance of excel (from a
different application), and you keep that instance hidden, it seems very
reasonable.



JHB wrote:

Sometimes the help files are useful, and sometimes not! In this case
they are not.

I want to shut down not only the spreadsheet but also the Excel
application with a macro. Its one of those things that should be
simple, but somehow I get tangled up with it, since shutting the
spreadsheet down also shuts down the macros, which means that Excel
doesn't get closed!

Suggestions for code would be appreciated by this neophyte!

Regards

John Baker


--

Dave Peterson

JHB

Close Excel with a Macro
 
On Aug 7, 7:48*am, Dave Peterson wrote:
Look at
Application.Quit
in VBA's help.

But this has never seemed like a very good idea to me. *

If I have multiple workbooks open and you quit excel, will you close those
workbooks?

How will you (the author of the code) know if I wanted to save a file, saveas a
new name or just close without saving?

You could have many users ticked off when they run your code.

======
On the other hand, if you're controlling your own instance of excel (from a
different application), and you keep that instance hidden, it seems very
reasonable.



JHB wrote:

Sometimes the help files are useful, and sometimes not! In this case
they are not.


I want to shut down not only the spreadsheet but also the Excel
application with a macro. Its one of those things that should be
simple, but somehow I get tangled up with it, since shutting the
spreadsheet down also shuts down the macros, which means that Excel
doesn't get closed!


Suggestions for code would be appreciated by this neophyte!


Regards


John Baker


--

Dave Peterson


Thanks..just needed a pointer. In fact this is an instance of Excel
that IS opened by an Access application, and I want to get it out of
the way after it executes.

John Baker


All times are GMT +1. The time now is 03:05 AM.

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