2013-09-26 113 views
0

最近,我已升級到傳統項目中工作。此應用程序是Enterprise Architect的一個插件,可將內容提取到.doc文件。關鍵是,我試圖從不同的地方引用dll,但沒有成功。未找到Microsoft.Office.Interop.Word參考

錯誤: 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)的\微軟的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的機器上測試。 欣賞任何幫助。

更新:

中「字」字加下劃線的代碼和編譯錯誤

到處都是上面。

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

嗯,這聽起來很奇怪。你能不能更新你的問題,幷包括你的代碼中的'using'語句,即'using Microsoft.Office.Interop.Word'?更好的是一個小樣本,說明哪一行導致編譯錯誤。 –

回答

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