Eccel in Protected View Errors in Macros RRS feed

  • Question

  • I have found that I get an error in a Workbook_WindowResize event macro, in particular. Workbook.Activate functions (although there may be others in the following circumstances.

    1. Workbook1 contains the macro, stored in its ThisWorkbook module;

    2. Workbook1 is minimised;

    3. When opening Workbook2 that has not previously been opened or it contains macros and it not trusted, in a separate instance (by holding Alt as I open the workbook), Workbook2 opens in Protected View with the yellow message bar across the top;

    4.  As this happens, Workbook1's Workbook_WindowResize appears to trigger and fails on the command Wookbook("name.xlsm").Sheets("sheetname").Activate produces a runtime error;

    5.  As soon as I've closed or acknowledged the Protected View message, I can continue to play the macro in VBE.

    I find this unexpected as I understood that opening the second workbook, Workbook2 in a separate instance should make these excel instances and the workbooks not interact.  I'm also confused as to why the Workbook_WindowResize event seems to trigger in Workbook1, since it's not active, the macro is in Workbook1's ThisWorkbook module and has not links or interaction with Workbook2.  So not only should the workbooks be running in completely independent instances of Excel an event macro store in one workbook should not trigger from another.

    I would appreciate if anyone has some ideas on why this is happening and how I can prevent the runtime error.  I could put in an onerror loop to wait for the Protected View message to go away, but this would add processing cycles.  By my logic this should not be occurring at all in any case.

    Thanks in advance,


    Sunday, August 25, 2019 8:28 AM

All replies

  • Hi,

    Based on your description, I will move thread to Excel for Developer forum:

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.


    Emi Zhang

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Office 2019.

    Monday, August 26, 2019 6:13 AM