Close Excel with a Macro

J

JHB

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
 
D

Dave Peterson

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.
 
J

JHB

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 (froma
different application), and you keep that instance hidden, it seems very
reasonable.

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
 

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