Word Automation - Disable Alerts

白昼怎懂夜的黑 提交于 2019-12-05 16:34:03

The portion of code that you have posted obviously looks correct, but there isn't enough for me to reproduce the behavior that you describe. However...

I have a strong suspicion the answer is that you can't completely suppress messages in Word. It was designed as a user-interactive application, and the DisplayAlerts setting is a bit of a hit-or-miss proposition. Certain errors look like they might be exempted from the specified alert setting and be displayed anyway. For example, I've seen spelling and grammar errors behave like this before.

The best thing to do is try to anticipate the errors that may occur and avoid generating them. In your case, you should be checking to see if the document you're about to open is already open. I'm not sure why you'd ever be generating this error in the first place (are you catching the error and then searching for the existing instance of the document to operate on it, or how does your code continue running?), but it should be fairly straightforward to insert a few guard clauses before you start executing the relevant code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!