Word Automation - disable alerts

I am automating Word, so I would like to suppress all warnings.

Word.Application word = new Word.Application(); word.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone; 

I use the code above, but I continue to receive messages from Word - for example, the document is already open. Is there any way to avoid this? How to suppress all these stupid messages?

EDIT :
Satisfying all the answers, I think that the watchdog is really the only option. Badly, nothing has changed in recent years.

The topic may be closed without a real answer.

+4
source share
1 answer

Part of the code you posted looks correct, but it’s not enough for me to reproduce the behavior you described. But...

I have a strong suspicion, and the answer is that you cannot completely suppress messages in Word. . It was developed as a user interactive application, and the DisplayAlerts parameter is a little suggestion to skip or skip. Some errors look as if they can be freed from the specified alert setting and displayed anyway. For example, I saw how spelling and grammar errors behave as before.

It is best to try to anticipate errors that may occur and not generate them. In your case, you should check if the document you are about to open is open. I'm not sure why you ever created this error (you catch the error and then look for an existing copy of the document to work on it, or how does your code continue to work?), But before you start executing the corresponding code, it should be pretty just insert a few protective sentences.

+3
source

All Articles