Share via

Microsoft Word API

Gregory Minasyants 1 Reputation point
Dec 7, 2020, 5:53 PM

Hello,

I have Office 365 installed on my machine. Particularly MS Word version is 2012.

I have created C# project (VS 2019) and referenced microsoft word 16.0 object. It appeared as C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Office.Interop.Word\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll.

at that following code

Application application = new Application();
var document = application.Documents.Open(args[0])

throws

System.InvalidCastException: 'Unable to cast COM object of type 'Microsoft.Office.Interop.Word.DocumentClass' to interface type 'Microsoft.Office.Interop.Word._Document'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0002096B-0000-0000-C000-000000000046}' failed due to the following error: Interface not registered (Exception from HRESULT: 0x80040155).'
exception. I have checked \HKEY_CLASSES_ROOT\Wow6432Node\Interface{0002096B-0000-0000-C000-000000000046}\TypeLib registry entry and it is empty (my machine is 64 bit).

I tried to run my executable on other machines but got the same error. Please advise.

Thanks.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
40,857 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    Dec 7, 2020, 6:51 PM

    Office development is not currently supported here on QnA. They're actively answering questions in dedicated forums here.
    https://social.msdn.microsoft.com/Forums/Lync/en-US/home?category=officedev

    --please don't forget to Accept as answer if the reply is helpful--


  2. Erin Ding-MSFT 4,461 Reputation points
    Dec 8, 2020, 7:28 AM

    @Gregory Minasyants

    Tag "office-word-itpro" focuses on general issues about Word clients.
    Since your issue is more related to Word API which is out of our scope of support and is not supported on Microsoft Q&A forum currently. I would modify the tag to be “not-supported”.
    If needed, you may post your issue on the Word for developers forum.

    Thanks for your understanding.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.