How to stop Excel from firing Worksheet_Change before Workbook_BeforeSave?

前端 未结 2 1348
情书的邮戳
情书的邮戳 2020-12-07 01:01

Update: Issue Resolved A colleague of mine was changing a cell during Workbook_BeforeSave() without disabling events, therefore triggerin

相关标签:
2条回答
  • 2020-12-07 01:13

    It was a coding mistake on our side:

    A colleague of mine was changing a cell during Workbook_BeforeSave() without disabling events, therefore triggering Worksheet_Change().

    The fix was easy. In Workbook_BeforeSave():

    Application.EnableEvents = False
    ' Some final changes
    Application.EnableEvents = True
    

    And that was it :)

    0 讨论(0)
  • 2020-12-07 01:27

    Add a global flag variable.

    Input a function that fires when key pressed and if CTRL + S it sets flag to true.

    The worksheet_change event should short circuit if this flag is true.

    And workbook_aftersave should change it back to false.

    0 讨论(0)
提交回复
热议问题