Problem in Opening Word 2010 using Visual Studio 2

2019-01-19 20:36发布

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条回答
女痞
2楼-- · 2019-01-19 21:12

Word 2010 must be installed on the machine.

查看更多
祖国的老花朵
3楼-- · 2019-01-19 21:16

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

查看更多
时光不老,我们不散
4楼-- · 2019-01-19 21:24

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.

查看更多
登录 后发表回答