Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I failed to reference the correct DLL for MS Word.
When I made a reference to Com/
Microsoft.Office.Interop.Word 15.0 object Library 8.6, Visual Studio also made a reference to Microsoft.Office.Core.

I used vstudio 2019 community.

Details about my PC
I installed MS Word 2013.
In control panel, one of the programs installed in my PC is
Microsoft Visual Studio 2010 Tools for Office run time(x64).

The PC is 64-bit operating system, x64-based processor.

The error I got is:

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: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).


What I have tried:

C#
using Microsoft.Office.Interop.Word;
using Word = Microsoft.Office.Interop.Word;
....
        private void button1_Click_1(object sender, EventArgs e)
        {
            Object oMissing = System.Reflection.Missing.Value;
            Object oFalse = false;
            Object name;

            Microsoft.Office.Interop.Word.Application wrdApp = 
                      new Microsoft.Office.Interop.Word.Application();
            Microsoft.Office.Interop.Word.Document wrdDoc = 
                      new Microsoft.Office.Interop.Word.Document();
            //wrdApp.Visible = true; //MS Word did not appear 
            Object ss = "KeleshaSanad.Docx";
            wrdDoc = wrdApp.Documents.Open(ref ss, ref oMissing,
            ref oMissing, ref oMissing, ref oMissing, ref oMissing,
            ref oMissing, ref oMissing, ref oMissing, ref oMissing,
            ref oMissing, ref oMissing, ref oMissing, ref oMissing,
            ref oMissing, ref oMissing);
        }
Posted
Updated 30-Oct-23 11:55am
v3
Comments
Richard MacCutchan 30-Oct-23 11:25am    
It may be that Word 2013 is 32 bit. Try rebuilding your application in 32-bit mode (x86) to see if that works.
Engineer khalid 30-Oct-23 12:03pm    
i change the cpu to x64 and run the program i got same error
then
i shift to (x86) that is 32bit and rerun program i got same error
Engineer khalid 30-Oct-23 12:26pm    
More information about the ms word 2013
by right clicking on ms word icon then selecting shortcut from upper tab menue then selecting advanced i see 2 checked boxes
a text beside the check box 1 (unchecked)sayes run as an administrator
this allows you to run this shortcut as an administrator,while protecting your computer from unauthorized activity.
the other text beside check box2 (its status checked)sayes
run in separate memory space
i could not change any checkbox

1 solution

This error displays that loaded library for the specified COM object which is referenced by your application does not contains the interface which you required.
If you using the some standard .NET libraries for accessing office objects you should remove them from the references. Find the related COM type libraries for your installed office Word and reference them. use those objects from that libraries in your implementation.
The type library which you should import as reference you can find in registry: HKLM\SOFTWARE\Classes\TypeLib\{00020905-0000-0000-C000-000000000046}\x.x\
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900