5
votes

I have been trying to open a Word document using C# in VS2010. But I have been successful so far. I have tried searching for answers but all in vain. In the reference section, I cannot see the Microsoft Word office library (any version) in the COM tab. I added the Microsoft.Office.Interop.Word. version 14 from the .Net tab, but still i get the same exception:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

Additional information: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

3

3 Answers

2
votes

You need to make sure that both Microsoft Office and Visual Studio Tools For Office (VSTO) are installed on the machine.

2
votes

VSTO is not the solution; Visual Studio 2010 has it built in.

I found the problem for me with the exact same error that you are getting was that I installed Office from the download using the "Click to run". I did download Office the first time I installed. This time I actually used the install DVD and now my code works perfectly. If you don't have the DVD then you can download the trial ISO file instead of the "Click to run" exe.

0
votes

Word 2010 must be installed on the machine.