从Worksheet.BeforeDoubleClick事件中取消保存更改提示

时间:2019-01-08 01:03:38

标签: excel vba

当我双击一个单元格以关闭Excel时,我可以取消保存更改提示;如何防止new code覆盖它?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Address(False, False) = "U1" Then
        Cancel = True
        Application.DisplayAlerts = False
        Application.Quit
    End If
End Sub

Private Sub Workbook_Open()
    ThisWorkbook.Saved = True
    With Application                                '<< New code
        .CommandBars.ExecuteMso "MinimizeRibbon"
        .DisplayFormulaBar = False
    End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    With Application                                '<< New code
        .CommandBars.ExecuteMso "MinimizeRibbon"
        .DisplayFormulaBar = True
    End With
End Sub

0 个答案:

没有答案