What is the difference between auto_open and workbook_open?

Title says it all....
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leo EikelmanDirector, IT and Business DevelopmentCommented:
The most important difference is this:

auto_open will not run when the workbook is opened by a macro. workbook_open will run if the workbook is opened by a macro.

In the first case (Auto_Open), you can use Workbook.RunAutoMacros to run the macro after opening the workbook.


Patrick MatthewsCommented:
Hi thandel,

Leo is correct.  I would just add that if you open a workbook with a Workbook_Open sub via code, you can keep
the event from firing with the line:

    Application.EnableEvents = False

right before you open it.  Be sure to turn events back on, though!



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thandelAuthor Commented:
What happens if a workbook had both... which executes first?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Leo EikelmanDirector, IT and Business DevelopmentCommented:
workbook_open executes first
thandelAuthor Commented:
Can you think of any reason why it wouldn't excute at all provided the workbook contained both and macros security etc was set to run?
Both would execute. The main difference is that Microsoft want to disown the Auto_Open, so support for that is likely to disappear at some unspecified time.
Leo EikelmanDirector, IT and Business DevelopmentCommented:
hmm doesn't execute at all?

If Application.EnableEvents = True then Is the Sub Workbook_Open() in the code view behind the workbook object (it needs to be).

As far as I understood this event should always fire in these circumstances, bit if it still doesnt then you could alternatively use Sub Auto_Open() in any code module (this should
also work regardless of whether Excel has events disabled).

there may be something wrong with the document.  Would it be difficult to move everything to a new document?

thandelAuthor Commented:
I poke around and ensure I have all set correctly.  Your information gives me an understanding.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.