Automatically executing macros

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
 
D

Dave Peterson

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