+ Reply to Thread
Results 1 to 4 of 4

Prevent Excel VBA Code from being Interrupted

  1. #1
    Rajeev
    Guest

    Prevent Excel VBA Code from being Interrupted

    Hi:

    I have a VBA code that is triggered when workbook is opened. If a user
    interrupts the execution (say, by pressing ESC key) as the code is being
    executed (code has multiple user authentication checks and reformmating and
    hiding of sheets per user's access level), the user gets this "Code
    Interruption Dialog" where they can click on End execution button. By
    pressing End button, the user can get access to undesired sheets/cells. My
    question is if I can stop this code interruption in Excel so that I can
    prevent access to undesired sheets/cells. Any ideas?

    Thanks
    Rajeev

  2. #2
    Rajeev
    Guest

    Don't Bother: Prevent Excel VBA Code from being Interrupted

    Found my answer through another Post
    Application.EnableCancelKey = xlDisabled
    in the the beginning of code to prevent it from being interrupted

    Thanks anyway

    "Rajeev" wrote:

    > Hi:
    >
    > I have a VBA code that is triggered when workbook is opened. If a user
    > interrupts the execution (say, by pressing ESC key) as the code is being
    > executed (code has multiple user authentication checks and reformmating and
    > hiding of sheets per user's access level), the user gets this "Code
    > Interruption Dialog" where they can click on End execution button. By
    > pressing End button, the user can get access to undesired sheets/cells. My
    > question is if I can stop this code interruption in Excel so that I can
    > prevent access to undesired sheets/cells. Any ideas?
    >
    > Thanks
    > Rajeev


  3. #3
    sebastienm
    Guest

    RE: Prevent Excel VBA Code from being Interrupted

    To prevent Cancellation, as first row of the _Open, use:
    application.EnableCancelKey=False
    then later reset it :
    application.EnableCancelKey=True

    Be aware that setting it to False can be a major problem if the code enters
    an infinite loop, you have no way to stop it and get back to design mode.

    For the "per user's access level", to prevent any problem of data
    visibility, hide all data sheets as xlSheetVeryHidden before saving the book
    so when it opens, nothing is visible, then after authentification, unhide the
    right sheets.

    Regards,
    Sebastien

    "Rajeev" wrote:

    > Hi:
    >
    > I have a VBA code that is triggered when workbook is opened. If a user
    > interrupts the execution (say, by pressing ESC key) as the code is being
    > executed (code has multiple user authentication checks and reformmating and
    > hiding of sheets per user's access level), the user gets this "Code
    > Interruption Dialog" where they can click on End execution button. By
    > pressing End button, the user can get access to undesired sheets/cells. My
    > question is if I can stop this code interruption in Excel so that I can
    > prevent access to undesired sheets/cells. Any ideas?
    >
    > Thanks
    > Rajeev


  4. #4
    quartz
    Guest

    RE: Prevent Excel VBA Code from being Interrupted

    Check out help on: Application.InterActive = False

    This command effectively locks the keyboard and mouse. Use it with caution,
    read help first.

    "Rajeev" wrote:

    > Hi:
    >
    > I have a VBA code that is triggered when workbook is opened. If a user
    > interrupts the execution (say, by pressing ESC key) as the code is being
    > executed (code has multiple user authentication checks and reformmating and
    > hiding of sheets per user's access level), the user gets this "Code
    > Interruption Dialog" where they can click on End execution button. By
    > pressing End button, the user can get access to undesired sheets/cells. My
    > question is if I can stop this code interruption in Excel so that I can
    > prevent access to undesired sheets/cells. Any ideas?
    >
    > Thanks
    > Rajeev


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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