Auto_Open vs. Workbook_beforeopen?

  • Thread starter Thread starter Hash
  • Start date Start date
H

Hash

All -

I don't understand the differences between Auto_open and
Workbook_beforeOpen, or those for their closing brethern.

Why should one be preferred over the other? Why are there two thigns
that do the same intent?

....best, Hash
 
Hi,
Workbook_Open will take precedence over Auto_Open. Auto_Open is only
provided for backward compatibility and will not fire when a workbook is
opened via code. VBA provides a RunAutoMacros method of the workbook which
allows the Workbook_Open event to fire when a workbook is opened via code.
The Workbook _Open event is contained in the ThisWorkbook Class of a
workbook, whereas the Auto_Open macro is contained in a standard Module.
I'm assuming you meant Workbook_Open as opposed to Workbook_BeforeOpen as
AFAIK this event doesn't exist. I don't see how it could. Hope this clears
it up for you.

Cheers,
O
 
Workbook_Open will take precedence over Auto_Open. Auto_Open is only
provided for backward compatibility and will not fire when a workbook is
opened via code

Just to add, Both Workbook_Open and Auto_Open would run if opened manually.

RunAutoMacros is a command you can use to run the Auto_Open macro (or
Auto_Close macro) as part of the same code that opens (or closes) the
workbook. the Workbook_Open macro runs whether the workbook is opened with
code or manually provided Events (an application level setting) are not
disabled.

BeforeClose and Auto_close have a similar relationship.
 
Oliver -

Thanks. Yes, I got the wrong name. Next version of Excel will
anticipate what spreadsheet we want opened. ;-) It'll be a feature.

It particularly helps about where the code goes.
....best, Hash
 

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