Automatically executing macros

  • Thread starter Thread starter k483
  • Start date Start date
K

k483

Is there a way for Excel to automatically execute (on loading) a macr
and then close? I'm trying to get it to automatically load--print
worksheet--close
 
If you recorded a macro to print what you wanted, you could rename it to
auto_open.

Then right before the "End Sub" add this line:

ThisWorkbook.Close savechanges:=False

But save your workbook before you test. When it hits that line, it closes your
workbook without saving.

And if you really wanted to close excel (irritating if the user has other open
workbooks), add:

application.quit

right after the "thisworkbook.close ..." line.
 

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

Back
Top