0

最近,我被升级到一个遗留项目中工作。此应用程序是 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 Tools for Office\PIA\Office14\Microsoft.Office.Interop.Word.dll C:\Windows\assembly\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)
    {...
    }
4

1 回答 1

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 复制过来。

(知道这已经快一年了,但现在只是设置一台新电脑......)

于 2014-08-20T10:38:51.053 回答