找不到Microsoft.Office.Interop.Word引用

时间:2013-09-26 20:30:34

标签: c# ms-word office-interop

最近,我已升级到遗留项目中工作。此应用程序是Enterprise Architect的插件,可将内容提取到.doc文件。关键是,我试图从不同的地方引用dll,但没有成功。

错误: The type or namespace name 'Word' does not exist in the namespace 'Microsoft.Office.Interop' (are you missing an assembly reference?)

我试过的地方参考: C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ Visual Studio工具用于Office \ PIA \ Office14 \ Microsoft.Office.Interop.Word.dll C:\的Windows \组件\ GAC_MSIL \的Microsoft.Office.Interop.Excel \ 15.0.0.0__71e9bce111e9429c \ Microsoft.Office.Interop.Word.dll

我正在使用Vistual Studio 2010,我在我的计算机上安装了Office 2013,但也在使用Office 2010的计算机上进行了测试。 感谢任何帮助。

更新

代码中的任何地方都有“Word”字样加下划线,编译错误在上面。

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
namespace EATec.Helpers
{
/// <summary>
/// Classe que manipula documento Word via Interop
/// </summary>
public class MSWordHelper
{
     private static object format = Microsoft.Office.Interop.Word.WdOpenFormat.wdOpenFormatAuto;
     private static object wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
    public static Microsoft.Office.Interop.Word.Document OpenDoc(object fileName)
    {...
    }

1 个答案:

答案 0 :(得分:0)

针对旧版Office的旧版应用程序可能正在做类似(C ++)的事情:

#import <msword9.olb>   rename("ExitWindows","ExitWindowsWRD") rename "FindText","FindTextWRD") rename("ReplaceText","ReplaceTextWRD") rename("RGB","RGBWRD")

当我设置一台新机器时,我有一个bat文件来重新注册旧文件:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regtlibv12 "C:\Source\Office 97 dlls\mso9.dll"
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regtlibv12 "C:\Source\Office 97 dlls\msword9.OLB"
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regtlibv12 "C:\Source\Office 97 dlls\vbe6ext.OLB"

当PC上安装了较新版本的Office时,必须这样做。

请注意,regtlibv12可能不在Windows 8 PC上,需要从旧PC上复制。

(知道这已经有将近一年了,但目前只是设置一台新电脑......)

相关问题