vba Excel 不提示在 Application.Quit 上保存未保存的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8438746/
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
Excel doesn't prompt to save unsaved files on Application.Quit
提问by Kuyenda
Using Application.Quit in Excel VBA is supposed to initiate the default quit procedure, which includes prompting the user to saved any unsaved documents currently open in the application.
在 Excel VBA 中使用 Application.Quit 应该启动默认的退出过程,其中包括提示用户保存当前在应用程序中打开的任何未保存的文档。
In testing across numerous systems (Excel 2010 32-bit, Windows 7 64-bit), I discovered that some systems prompt the user to save, and some systems do not.
在众多系统(Excel 2010 32位、Windows 7 64位)的测试中,我发现有的系统提示用户保存,有的系统不提示。
We checked the settings across the systems (including enabling all macros and disabling protected view) to no avail. Even using the same settings on the different systems did not force the one system to prompt the user to save their work before Excel shuts down.
我们检查了整个系统的设置(包括启用所有宏和禁用受保护的视图)无济于事。即使在不同的系统上使用相同的设置,也不会强制一个系统在 Excel 关闭之前提示用户保存他们的工作。
It's as if Application.DisplayAlerts has been set to False, but it hasn't. We even tried the following lines of code:
就好像 Application.DisplayAlerts 已设置为 False,但事实并非如此。我们甚至尝试了以下几行代码:
Application.DisplayAlerts = True
Application.Quit
On certain systems, even that still doesn't prompt the user to saved unsaved documents. Excel just suddenly shuts down.
在某些系统上,即使这样仍然不会提示用户保存未保存的文档。Excel 只是突然关闭。
Any help solving this is greatly appreciated.
非常感谢任何帮助解决这个问题。
Thanks!
谢谢!
Update in response to comments:
根据评论更新:
I double checked the Workbooks.Saved property for all the workbooks that were opened and unsaved and it was false just before Application.Quit, so that must not be the problem.
我仔细检查了所有打开和未保存的工作簿的 Workbooks.Saved 属性,在 Application.Quit 之前它是假的,所以这一定不是问题。
I also just ran a simple test. I opened a workbook, edited it and executed Application.Quit in the immediate window in VBA. Excel quit without prompting to save the unsaved file. This indicates to me that it is something about my Excel setup and has nothing to do with my application.
我也只是进行了一个简单的测试。我打开一个工作簿,编辑它并在 VBA 的即时窗口中执行 Application.Quit。Excel 退出而不提示保存未保存的文件。这向我表明这与我的 Excel 设置有关,与我的应用程序无关。
回答by Kuyenda
Disabling the Solver Add-In returns the normal behavior.
禁用规划求解插件返回正常行为。
回答by Jpi
I was using the following code to save the workbook and close the application
我使用以下代码保存工作簿并关闭应用程序
ActiveWorkbook.Save
Application.Quit
but after a crash excel asked me to disable the Solver. After disabling the solver Excel didn't recognise the save command and it was continuing to ask if I wanted to save the workbook despite the save command.
但在崩溃后,excel 要求我禁用求解器。禁用求解器后,Excel 无法识别保存命令,它继续询问我是否想保存工作簿,尽管有保存命令。
Then I have figured out that this bug could be solved by enable again the solver...
然后我发现这个错误可以通过再次启用求解器来解决......
very weird
很奇怪
回答by Cole Walker
I tried the same thing of disabling the Solver Add-In and that did not work. I decided to also try disabling the Hstbar Add-In. Both of them disabled made the prompt start working again.
我尝试了禁用 Solver Add-In 的相同方法,但没有奏效。我决定也尝试禁用 Hstbar 插件。他们都被禁用使提示再次开始工作。