The conditions are as follows. There is an opened Word document. When I try to open another document in this way:
var application = new Application // the window appears on this line
{
Visible = true,
DisplayAlerts = WdAlertLevel.wdAlertsNone,
};
var document = application.Documents.Open(pathToFile);
Microsoft Word Security Notice window pops up:
When I close this window manually, another Word document launches with no problem. I have also tried to add a property:
var application = new Application
{
Visible = true,
DisplayAlerts = WdAlertLevel.wdAlertsNone,
AutomationSecurity = MsoAutomationSecurity.msoAutomationSecurityForceDisable
};
But that didn't help either. I found a post with a similar problem posted 5 years ago: Disable Macros Automatically Microsoft Word Interop.
But I don't need to disable the ability to run macros, I just need to somehow make this window not appear. Or automatically close it. Judging by what I have read, it is almost impossible to do this. But hope dies last :)
P.S. This problem is not present in Excel and PowerPoint for some reason.
I was able to deal with this problem in this way: