如何取消Workbook_BeforeSave

问题描述 投票:0回答:1

我从 Microsoft 网站获得了此代码。

无论我选择“是”还是“否”,文件都会保存。

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel as Boolean)
 
a = MsgBox("Do you really want to save the workbook?", vbYesNo) 
If a = vbNo Then Cancel = True 

End Sub
excel vba
1个回答
1
投票

如果你测试会发生什么

IF MsgBox("Do you really want to save the workbook?", vbYesNo) = vbNo then Cancel=True
© www.soinside.com 2019 - 2024. All rights reserved.