Word automation - Element not found

%3CLINGO-SUB%20id%3D%22lingo-sub-2138610%22%20slang%3D%22en-US%22%3EWord%20automation%20-%20Element%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2138610%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20PowerShell%20script%20running%20on%20Windows%2010%20(fully%20patched)%20with%20Office%20365.%20On%20my%20PC%2C%20the%20lines%3C%2FP%3E%3CP%3E%24word%20%3D%20New-Object%20-comobject%20Word.Application%3CBR%20%2F%3E%24word.Visible%20%3D%20%24false%3C%2FP%3E%3CP%3Efail%20on%20the%20second%20line%20with%3A%3C%2FP%3E%3CP%3EException%20setting%20%22Visible%22%3A%20%22Unable%20to%20cast%20COM%20object%20of%20type%20'Microsoft.Office.Interop.Word.ApplicationClass'%20to%20interface%20type%20'Microsoft.Office.Interop.Word._Application'.%20This%20operation%20failed%20because%20the%20QueryInterface%20call%20on%20the%20COM%20component%20for%3CBR%20%2F%3Ethe%20interface%20with%20IID%20'%7B00020970-0000-0000-C000-000000000046%7D'%20failed%20due%20to%20the%20following%20error%3A%20Element%20not%20found.%20(Exception%20from%20HRESULT%3A%200x8002802B%20(TYPE_E_ELEMENTNOTFOUND)).%22%3C%2FP%3E%3CP%3EAnd%20the%20%24word%20object%20is%20empty.%3C%2FP%3E%3CP%3EThis%20used%20to%20work%20and%20if%20I%20run%20the%20same%20script%20on%20a%20Windows%2010%20(fully%20patched)%20VM%20with%20another%20licence%20to%20the%20same%20Office%20365%20subscription%2C%20it%20works.%20Is%20there%20some%20Word%20setting%20I%20need%20to%20change%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2138610%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWord%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

I have a PowerShell script running on Windows 10 (fully patched) with Office 365. On my PC, the lines

$word = New-Object -comobject Word.Application
$word.Visible = $false

fail on the second line with:

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))."

And the $word object is empty.

This used to work and if I run the same script on a Windows 10 (fully patched) VM with another licence to the same Office 365 subscription, it works. Is there some Word setting I need to change?

0 Replies