• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

What is the difference between auto_open and workbook_open?

Title says it all....
0
thandel
Asked:
thandel
2 Solutions
 
Leo EikelmanCommented:
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.

Cheers,

Leo
0
 
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!

Regards,

Patrick
0
 
thandelAuthor Commented:
What happens if a workbook had both... which executes first?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Leo EikelmanCommented:
workbook_open executes first
0
 
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?
0
 
GrahamSkanCommented:
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.
0
 
Leo EikelmanCommented:
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?


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

Thanks.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now