question

Tanmayee-2418 avatar image
0 Votes"
Tanmayee-2418 asked JackJJun-MSFT commented

Handle word pop ups while running an automated code using Interop




We have .NET automation code for processing a word document - this is being invoked from Automation Anywhere. Using the Interop's 'word.DisplayOptions' method, most of the anticipated pop ups have been handled, however, there are few intermittent pop ups at word application level which is causing our automated run to fail. Please give me some suggestions to handle such issues.

Requirement: Make formatting changes in word document and add relevant comments based on flags set in excel sheet. This .NET code is invoked by a bot after certain conditions are met. However, when there is any word document level pop up , bot is unable to handle it and hence fails.

For now, we have the following code which handles pop ups and other such alerts at microsoft word level. MsWord.Application wdApplication = new MsWord.Application(); wdApplication.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable; wdApplication.DisplayAlerts = WdAlertLevel.wdAlertsNone;

However, when there are pop ups at application level, there is no way I could figure out. The text in pop up: 'Duplicate file is already open by someone and hence cannot be processed';'Call was rejected by callee';'Microsoft Office can't find your license for the repair attempt';'The file is read-only. Do you wish to save it?'

dotnet-csharp
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Tanmayee-2418 , do you want to disable all the pop ups you mentioned in the last of the question? Could you provide the automated code ? It will help me to reproduce your problem.

0 Votes 0 ·

yes, it is an unattended bot and these pop ups are not letting the bot proceed. Attached is the method being invoked in DLL call from bot - I have removed most repetitive parts for simplicity124292-method.txt


0 Votes 0 ·
method.txt (12.1 KiB)

@Tanmayee-2418 , Sorry for the late response, based on my further research, I suggest that you need to solve the specific problem when you meet the pop up. For example, Duplicate file is already open by someone and hence cannot be processed, then it is best for you to check if your word file has been running in the task manager. Also, Based on my test, there is such built-in method to disable the pop up by using the code.

0 Votes 0 ·

An alternative is to use Open XML for Word.

  • Upside No display alerts

  • Upside Word does not have to be installed and is not version dependent

  • Downside More work to edit documents

Documentation some code samples productivity pack

We use a third party library which makes working with word documents easier than without a library.





0 Votes 0 ·

we were not sure if OpenXml provides extensibility to work with track revisions/changes too. Few requirements involved reading the track changes. Hence, Interop was chosen

0 Votes 0 ·

0 Answers