PDA

View Full Version : Solved: Open another workbook w/o macros executing



MWE
11-19-2005, 08:10 AM
Assume a workbook, A.xls, that has some "workbook_open" macros. I wish to open A.xls from B.xls and not have the workbook_open macros in A.xls execute.

I have done this before, but it was 3 years ago and I can not find the original code. I believe it was as simple as setting a parameter in the Workbooks.Open method, but poking around VBA Help has not turned up anything useful.

Thanks

johnske
11-19-2005, 08:44 AM
In the Workbook_Open code in workbook A put an If...Then test to see if Workbook B is open (if it's open exit the Workbook_Open procedure). Here's an example of the test that you can adapt to suit http://www.vbaexpress.com/kb/getarticle.php?kb_id=443

MWE
11-19-2005, 09:03 AM
In the Workbook_Open code in workbook A put an If...Then test to see if Workbook B is open (if it's open exit the Workbook_Open procedure). Here's an example of the test that you can adapt to suit http://www.vbaexpress.com/kb/getarticle.php?kb_id=443
Thanks for the prompt reply. The recommended approach will work for the particular case, i.e., we know beforehand that B will be opening A, but not for the general case where some workbook is opening another workbook and we do not want any workbook_open macros in the 2nd workbook to execute.

Insomniac
11-19-2005, 06:29 PM
Use:Application.EnableEvents = False
'Open Workbook>> do Stuff
Application.EnableEvents = True
Be aware that EnableEvents = False will disable all events in all Workbooks & Addins, including the one running the code.
Also any OnTime code will still fire with events disabled, and that code can possibly turn events back on.

MWE
11-22-2005, 10:21 AM
Use:Application.EnableEvents = False
'Open Workbook>> do Stuff
Application.EnableEvents = True
Be aware that EnableEvents = False will disable all events in all Workbooks & Addins, including the one running the code.
Also any OnTime code will still fire with events disabled, and that code can possibly turn events back on.
Thanks; this works great.