Word._Application WordApp = null;
WordApp = new Word.Application();
WordApp.Visible = false;
'((Microsoft.Office.Interop.Word.ApplicationClass)WordApp).ActiveDocument' threw an exception of type 'System.InvalidCastException'
{"Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID
'{00020970-0000-0000-C000-000000000046}' failed due to the following error: Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND))."}
Same thing happens in Powershell:
#3 [17:20:38] PS> Add-Type -Assembly "Microsoft.Office.Interop.Word"
#4 [17:20:43] PS> $app = New-Object Microsoft.Office.Interop.Word.ApplicationClass
#5 [17:20:53] PS> $app.Visible = $false
Exception setting "Visible": "Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to
interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on
the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following
error: Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND))."
At line:1 char:1
+ $app.Visible = $false
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting
Systems are enterprise workstations with Office365 (Microsoft Word for Office365 MSO 32bit is what the About Word says).
I've tried the nuget package for interop.word as well as the default one from the Office15 folder in ProgramFiles(32bit).