View Full Version : Solved: Open another workbook w/o macros executing
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
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.
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.