Workbook_beforesave Problem

  • I have the following code in the "ThisWorkbook" section of an excel file.


    Code
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
        
        Application.ScreenUpdating = False
        UpdateInitiativeData
        UpdateInitiativeList
        Application.ScreenUpdating = True
        MsgBox "Successful"
    
    
    End Sub


    Where UpdateInitiativeData and UpdateInitiativeList are two subs also in the "ThisWorkbook" section.


    For some reason when I save the file, nothing runs. The message box does not even popup. Any suggestions on how to fix this? I've even tried Taking all the code out of the "ThisWorkbook" section except for:


    Code
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
        
        MsgBox "Successful"
    
    
    End Sub


    And I've had no luck with that either. No message box popup.


    Thanks in advance!

  • Re: Workbook_beforesave Not Acting Properly


    Hi eduboys,


    Possibly your Enable Events is False.


    Try putting this code in anywhere in the Code window and run it, then try Save.


    Code
    Sub Enable()
        Application.EnableEvents = True
    End Sub


    Bill

  • Re: Workbook_beforesave Not Acting Properly


    Amazing!


    Any idea why all of a sudden the events would be disabled as I've never written any code using that functionality? Could it be due to a plugin that was installed on my machine? Hyperion Essbase possibly?

  • Re: Workbook_beforesave Not Acting Properly


    Hi eduboys,


    Sometimes when code is run, if there is a debug and the Events have been disabled by the code or macro, then the Events remain Disabled.


    Bill

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!