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)).
You need to make sure that both Microsoft Office and Visual Studio Tools For Office (VSTO) are installed on the machine.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With