unable to close macro using auto_close or application.quit

  • Thread starter Thread starter gloria
  • Start date Start date
G

gloria

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
 
Hi Gloria,
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

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:

Workbooks("Yourbooksname.xls").Saved=True

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.

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com
 
Back
Top