最近,我被升级到一个遗留项目中工作。此应用程序是 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)
{...
}