📜  excel vba 关闭而不保存 - VBA 代码示例

📅  最后修改于: 2022-03-11 14:51:52.995000             🧑  作者: Mango

代码示例2
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Cancel = True                       ' Cancels in any case
    ' Or :
    If SaveAsUI Then Cancel = True      ' Cancels only if saving is asked by user, not via code
End Sub

' Prevents Excel from requesting a save before closing
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.ThisWorkbook.Saved = True
End Sub