open a workbook with events turned off  
Author Message
Joe_D





PostPosted: Visual Basic for Applications (VBA), open a workbook with events turned off Top

Is there a way to open a workbook with the events disabled   In other words, I would like to open a workbook so that links can be updated, but without executing the workbook_open or workbook_activate event procedures.

Microsoft ISV Community Center Forums3  
 
 
Derek Smyth





PostPosted: Visual Basic for Applications (VBA), open a workbook with events turned off Top

Hi,

If you set your Macro security to medium or high then when you open the spreadsheet you will be prompted to enable or disable macros. If you select disable then your sheet will open but no code will run.



 
 
Joe_D





PostPosted: Visual Basic for Applications (VBA), open a workbook with events turned off Top

Thanks for your reply, but I did not quite explain my issue correctly. I would like to open a series of workbooks via VBA code, without triggering the events.
 
 
Derek Smyth





PostPosted: Visual Basic for Applications (VBA), open a workbook with events turned off Top

Joe,

I'm not sure if you can do what your asking. The code in the Workbook_Open event should fire as the workbook is being opened. A different approach might be to extract the data from the spreadsheet which you can do using ADO, there is an example on my blog.



 
 
Joe_D





PostPosted: Visual Basic for Applications (VBA), open a workbook with events turned off Top

Aparrently, you can do it by disabling events just before opening the other workbook and reenabling the events just after closing it. This only works if you do not execute an enableevents in the other workbook while processing in it.
 
 
Derek Smyth





PostPosted: Visual Basic for Applications (VBA), open a workbook with events turned off Top

Nice one Joe, just encase anyone else needs to know here is an example:

Application.EnableEvents = False
ActiveWorkbook.Save
Application.EnableEvents = True