Problem in Opening Word 2010 using Visual Studio 2010?
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: http://www.microsoft.com/downloads/details.aspx?FamilyId=5E86CAB3-6FD6-4955-B979-E1676DB6B3CB&displaylang=en
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.
Word 2010 must be installed on the machine.
精彩评论