unable to close macro using auto_close or application.quit

unable to close macro using auto_close or application.quit

Post by glori » Thu, 15 Jan 2004 15:19:52

I have a macro that is processed using sub auto via a
hyperlink. Basically, if someone cick the hyperlink it
will run the macro. All the processing is invisible. Now,
when this marco is run by just clicking the excel
application it will run invisible and end he application
invisible. However, when this marco is processed using
the hyperlink, it will process invisible, but at the end
it will show the sheet that i use to create the marco. I
have used application.quit or auto_close, however, they
rerun the process again and again. I am not able to use
any of the close statment to shut of the application one
the macro ends. Basically, i do not want the user to see
the excel application. thanks in advance

unable to close macro using auto_close or application.quit

Post by Jan Karel » Thu, 15 Jan 2004 16:50:48

Hi Gloria,

When your macro has finished its work, add
Application.Quit as the last statement in the routine that is last
executed before the macro reaches its end.

You must make sure that all open workbooks are saved or closed (except
the one with the macro) without saving before this will work though.

To tell excel a workbook does not have to be saved when closing, use:

Workbooks("Yourbooksname.xls").Close SaveChanges:=False

Or alternatively set:


This will tell Excel to forget whether any change has been made to a
workbook and it will close it without prompting for a save when you
quit Excel.


Jan Karel Pieterse
Excel MVP