使用 Visual Studio 2010 打开 Word 2010 时出现问题? [英] Problem in Opening Word 2010 using Visual Studio 2010?

查看:16
本文介绍了使用 Visual Studio 2010 打开 Word 2010 时出现问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在 VS2010 中使用 C# 打开 Word 文档.但到目前为止我已经成功了.我试图寻找答案,但都是徒劳的.在参考部分,我在 COM 选项卡中看不到 Microsoft Word 办公库(任何版本).我添加了 Microsoft.Office.Interop.Word..Net 选项卡中的版本 14,但我仍然遇到相同的异常:

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:

未处理的异常类型'System.Runtime.InteropServices.COMException'发生在 mscorlib.dll

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

附加信息:由于以下错误,检索 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件的 COM 类工厂失败:80040154 类未注册(HRESULT 异常:0x80040REG_TE54).>

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)).

推荐答案

VSTO 不是解决方案;Visual Studio 2010 内置了它.

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

我发现我遇到的问题与您遇到的完全相同的错误是我使用单击以运行"从下载中安装了 Office.我第一次安装时确实下载了Office.这次我实际上使用了安装 DVD,现在我的代码运行良好.如果您没有 DVD,则可以下载试用版 ISO 文件,而不是点击运行"exe.

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.

这篇关于使用 Visual Studio 2010 打开 Word 2010 时出现问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆