Consulting

Results 1 to 6 of 6

Thread: An application.EnableEvents issue. Help needed.

  1. #1
    VBAX Tutor
    Joined
    Jun 2005
    Posts
    214
    Location

    An application.EnableEvents issue. Help needed.

    Hi All,

    Does someone know how to close a workbook without saving changes if Application.EnableEvents is set to False (when opening the worbook).

    And how to set it back to Application.EnableEvents = True, just before closing the workbook.
    Seems impossible to do. But maybe someone knows a workaround?

    The thing is, Private Sub Workbook_BeforeClose(Cancel As Boolean) does not respond if EnableEvents = False.

    regards,
    Stranno

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    which codes do not run as a result of the disabled events?

    post all the codes or workbook(s) pls...
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    If events are disabled, it would require manual code to do that.
    Be as you wish to seem

  4. #4
    VBAX Tutor
    Joined
    Jun 2005
    Posts
    214
    Location
    Quote Originally Posted by mancubus View Post
    which codes do not run as a result of the disabled events?

    post all the codes or workbook(s) pls...
    Attached Files Attached Files

  5. #5
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,873
    1.Save the file with the read-only recommended option set? Perhaps with a password if you want.

    2. Don't set applicationevents=false but use a different method to stop event-handlers' code operating, such as a global variable being set (eg a boolean EventBlocked variable) and each event-handler code starting with
    If Not EventBlocked then
    'the usual event code
    End If
    then set the boolean variable elsewhere. This means you'll be able to control any or all of the event handlers, even being more choosy by using more than one such boolean variable.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  6. #6
    VBAX Tutor
    Joined
    Jun 2005
    Posts
    214
    Location
    Quote Originally Posted by p45cal View Post
    1.Save the file with the read-only recommended option set? Perhaps with a password if you want.

    2. Don't set applicationevents=false but use a different method to stop event-handlers' code operating, such as a global variable being set (eg a boolean EventBlocked variable) and each event-handler code starting with
    If Not EventBlocked then
    'the usual event code
    End If
    then set the boolean variable elsewhere. This means you'll be able to control any or all of the event handlers, even being more choosy by using more than one such boolean variable.
    Thanks again p45cal. It's a lot of work (in my case) but I think it's the only solution.

Posting Permissions

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