我已经设置了一个例程来在关闭之前保存我的加载项,如下所示:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ThisWorkbook.Saved = False Then ThisWorkbook.Save
End Sub
仍然Excel提示我这条消息"想要将更改保存到(文件名)?"
在我执行宏期间开始更改isAddin属性后,我开始收到此消息。
如何摆脱这条消息。
答案 0 :(得分:1)
看看是否有效
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
If ThisWorkbook.Saved = False Then ThisWorkbook.Save
Application.DisplayAlerts = True
End Sub
答案 1 :(得分:1)
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
If ThisWorkbook.Saved = False Then ThisWorkbook.Save
Application.DisplayAlerts = True
thisworkbook.close
End Sub
还建议添加一个错误语句来将Application.DisplayAlerts设置回true