vba 如何在长时间运行的 word 宏中禁用屏幕更新?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17670085/
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 disable screen update in long running word macro?
提问by Sam
I've got a word 2013 macro which is taking quite some time to finish.
我有一个 word 2013 宏需要很长时间才能完成。
The macro is reformatting the document and the Screen keeps updating while the macro is running, which I guess is where word spends most of it's time.
宏正在重新格式化文档,并且屏幕在宏运行时不断更新,我猜这是 word 花费大部分时间的地方。
How can I disable screen updating in word in a macro and refresh it when the macro is finished?
如何在宏中禁用 word 中的屏幕更新并在宏完成后刷新它?
回答by Kazimierz Jawor
Try with adding this line at the beginning of your code:
尝试在代码的开头添加这一行:
Application.ScreenUpdating = False
and this at the end:
最后是:
Application.ScreenUpdating = True
If this doesn't help you need to add more information and possibly post your code.
如果这没有帮助,您需要添加更多信息并可能发布您的代码。