如何在 Excel-VBA 中避免保存 MessageBox 提示?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6824816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to avert the save MessageBox prompt in Excel-VBA?
提问by Vivian
I have a problem here if you look at my codes below after I call the .close
line which was the file I initially copied from. It will prompt a save MessageBox message either yes, no, or cancel. Is there anyway I can avoid this save message from appearing programmatic if no was the case could I just programmatic program it no
instead?
如果您在调用.close
我最初从中复制的文件的行之后查看下面的代码,我会遇到问题。它将提示保存 MessageBox 消息是、否或取消。无论如何,我是否可以避免此保存消息以编程方式出现,如果不是这样,我可以no
改为以编程方式对其进行编程吗?
回答by datatoo
Jon is right to suggest Application.DisplayAlerts and if you want to answer no to a save as you suggest
Jon 建议 Application.DisplayAlerts 是正确的,如果您想按照您的建议回答不保存
Workbooks(Filename1).Close SaveChanges:=False
回答by Jon Raynor
Try setting the Application.DisplayAlerts to false, then closing. I recommend turning it back on after setting it.
尝试将 Application.DisplayAlerts 设置为 false,然后关闭。我建议在设置后重新打开它。
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
回答by RBarryYoung
IIRC:
国际研究中心:
Workbooks(FileName1).Save
If you save it explicitly, it won't have to ask you.
如果您明确保存它,它就不必询问您。