简体   繁体   中英

Open workbook from another workbook without firing the open workbook event?

I have two workbooks integrated into the following workflow:

1. I export data from WB1 into WB2
2. I want to check, whether the data in WB2 are up to date.

In my VBA Code in WB1 I use

Workbooks.Open "C:\WorkbookName.xls"

to get my data from WB1 into WB2 .

In WB2 I have VBA Code within the Open Event to check it the data is up to date.

PROBLEM: If I use Workbooks.Open "C:\\WorkbookName.xls" the Open Event fires. Is it possible to avoid that and to manipulate the WB2 from WB1 without to activate the Open Event ?

This can be done by disabling the events before opening the file:

Application.EnableEvents = False 

After opening the file you can enable the events again:

Application.EnableEvents = True

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM