I need to disable macros if a workbook is opened by a user (referred to as '1st workbook') but I don't want the macros disabled if the workbook is opened via VBA code from another workbook (referred to as '2nd workbook').
See the code 'workbook_open' that I currently have (in '1st workbook'), which disables the macros & works fine when opened by a user.
To get around this 'workbook_open' code when I open '1st workbook' via the VBA code in '2nd workbook', I have the following code "From 2nd workbook". However, disabling events code in '2nd workbook' doesn't work because the macros in '1st workbook' are disabled when the '2nd workbook' opens it..
I suspect that my problem is that the 'Application.EnableEvents = False' is only applied to the activeworkbook and there not applied to '1st workbook' (because it is not yet opened). Thus the 'Workbook_Open' event in '1st workbook' is still executed upon it's opening.
Hmm, maybe I need to state which workbook to apply 'Application.EnableEvents = False' to? If so, can anyone please recommend the best way to do that please?
Or any other suggestions please?
' From 1st workbook
Dim secAutomation As MsoAutomationSecurity
secAutomation = Application.AutomationSecurity
Application.AutomationSecurity = msoAutomationSecurityForceDisable
' From 2nd workbook
Application.EnableEvents = False
Application.EnableEvents = True