+ Reply to Thread
Results 1 to 25 of 25

Delay workbook opening to avoid protection mode error

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Delay workbook opening to avoid protection mode error

    Hi Guys,

    i have an issue while workbook is opened (error) in protected mode.

    The problem was described here:

    https://support.microsoft.com/en-us/...-exiting-prote

    I added new Class1 and put the code from link there but i do not know how to test it, how to invoke protected mode to test it?
    It sometimes appearing for me , sometimes not.

    Please help - Did i do this properly by adding code into Class1 class?

    Please help
    Jacek
    Last edited by jaryszek; 04-17-2020 at 03:59 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,702

    Re: Differ workbook opening to avoid protection mode error

    Is this the same as your other thread?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Differ workbook opening to avoid protection mode error

    Which thread?

    Jacek

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,702

    Re: Differ workbook opening to avoid protection mode error


  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Differ workbook opening to avoid protection mode error

    Nope,

    why i would create 2 the same theads?

    From Link is about unlocking VBE project password.
    From this topic is about protected mode and opening excel which is causing workkook_activate event to fail...

    Jacek

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,702

    Re: Differ workbook opening to avoid protection mode error

    That's why I am asking - thanks for clarifying.

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    Hi Guys,

    anyone was trying to use the class from link?
    It is working for you?

    Jacek

  8. #8
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    Anyone please?

    Can help with implementation which will work?

    Jacek

  9. #9
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    Hi,

    Bump, can anybody help?

    Jacek

  10. #10
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    Anyone please help

    Jacek

  11. #11
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    Bump,

    anyone can help?

    Jacek

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,300

    Re: Delay workbook opening to avoid protection mode error

    You haven't given enough information. Where is the code that is failing?
    Anyone who confuses correlation and causation ends up dead.

  13. #13
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    Hi rory,

    I do not know how to implement the code from microsoft link above:

    Please Login or Register  to view this content.
    I added code into class module.
    but this is not working.
    It is not catching protected mode.

    Best,
    Jacek

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,300

    Re: Delay workbook opening to avoid protection mode error

    You didn't answer my question. Where is the code that is failing?In the same workbook, in an add-in, in some other program...?

  15. #15
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    In the same workbook.

    It is workbook open event:

    Please Login or Register  to view this content.
    Best,
    Jacek

  16. #16
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,300

    Re: Delay workbook opening to avoid protection mode error

    It says quite clearly in that article that it won't work in a Workbook_Open event. Since the code in that sample is for an external app, you don't need a separate class (your ThisWorkbook is already a class). You need to implement a similar hand off to a Workbook_Activate event instead, or just move your code to that event if you can.

  17. #17
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    Hmm let me think how to solve this on example.

    I will try to add something to google drive and open in protected view to test.

    I will let you know about results,
    Best,
    Jacek

  18. #18
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    Ok Guys,

    I am returnng back with feedback and asking for your confirmation and suggestions.

    I created 2 workbooks:

    TestWithoutHandler:

    Please Login or Register  to view this content.
    which i put on google disc:
    https://drive.google.com/open?id=10c...yj6d5jPZXDMr1n

    Also i created workbook with handler:

    Please Login or Register  to view this content.
    Google Disc:
    https://drive.google.com/open?id=1RX...A1QN8Z_DOyiGuu

    i am also adding them as attachment.
    To invoke protected mode you can upload these workbooks into google drive and just download, after opening it will be opened in protected mode.

    The second workbook with handler seems to be working fine. The first one throws error on workbook.activate method (like in my original workbook).

    Can anybody confirm that this code is enaugh to solve the issue in this case ?:

    Please Login or Register  to view this content.
    It is very interesting.

    Best wishes,
    Jacek
    Attached Files Attached Files

  19. #19
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    Ok i checked on my main workbook (17 MB) and this is not working...

    I think here:

    Please Login or Register  to view this content.
    i should have some kind of loop in order to make this work to TRULY delay workbook opening.
    Can anybody advice?

    I do not catch how the original code can delay workbook opening. It is just changing boolean to TRUE...

    Jacek

  20. #20
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,300

    Re: Delay workbook opening to avoid protection mode error

    You didn't implement the suggested code as you don't have a Workbook_Activate event that I can see.

  21. #21
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    Hi,

    because this is the same instance. I tried to do as one instance.
    How can i do this?

    Jacek

  22. #22
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,300

    Re: Delay workbook opening to avoid protection mode error

    The point is that if the workbook is in protected mode, the code simply sets a Boolean flag (your line is commented out, so it doesn't actually do anything) and then you have an additional Workbook_Activate event that only does anything if that flag is set (it also sets it to false so it won't run again if you, say, switch between workbooks).

  23. #23
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    thanks rory.

    so what was wrong in original code?
    I tried to change it and now this is not ok.
    So i should have workbooks_open event? Or not?

    What should i do?

    Can you please help?
    Where should i put Application.Event?

    i put all code to the ThisWorkbook class:

    Please Login or Register  to view this content.
    This is ok?

    edit2: The code above pasted into ThisWorkbook class is not working...

    Jacek
    Last edited by jaryszek; 04-27-2020 at 06:17 AM.

  24. #24
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,300

    Re: Delay workbook opening to avoid protection mode error

    You don't need all that if the code is in the workbook being opened. Just:

    Please Login or Register  to view this content.

  25. #25
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Delay workbook opening to avoid protection mode error

    You are MAster!!!!

    thank you Rory, respect!

    Jacek

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Workbook is opening in vba edit mode
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-15-2017, 12:56 PM
  2. 'Can't exit design mode' error when workbook opened on some machines only!
    By MathUKTeacher in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-17-2015, 05:40 PM
  3. [SOLVED] Protection Mode...
    By gharding14 in forum Excel General
    Replies: 2
    Last Post: 10-20-2014, 03:00 PM
  4. Replies: 5
    Last Post: 05-30-2014, 04:53 AM
  5. [SOLVED] assign code to avoid the pop up comp-ability check mode save option
    By johnodys in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-31-2013, 09:27 AM
  6. Error when opening workbook
    By stephenw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-04-2007, 08:55 PM
  7. Replies: 1
    Last Post: 10-10-2005, 03:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1