在 Visual studio 2013 中使用 winword 或 excel 库

Using winword or excel library in Visual studio 2013

我需要在我的 dotNet 4.5 代码中以编程方式访问 word 和 excel 文件。我正在使用 Visual Studio 2013。我添加了对 DLL Microsoft Office 14.0 DLL 的引用并使用了以下代码行:

using Word = Microsoft.Office.Interop.Word;

但是在尝试 运行 应用程序时出现以下错误:

The type or namespace name 'Interop' does not exist in the namespace 'Microsoft.Office'

您需要将MSword Interop 添加到您的项目中。 Add reference->assemblies->Extensions 找到您要添加的互操作并添加它。

Here 是对 interop dll 的一点解释。