【发布时间】:2014-09-26 09:00:41
【问题描述】:
我正在阅读tutorial on how to use control blocks to manipulate document in word。
问题是声明:
private Microsoft.Office.Tools.Word.Controls.Button button = null;
给出错误。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;
namespace SecondWordAddIns {
public partial class ThisAddIn {
private Microsoft.Office.Tools.Word.Controls.Button button = null; // error here
private RichTextContentControl richTextControl = null;
private void ThisAddIn_Startup(object sender, System.EventArgs e) { }
private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { }
internal void toggleButton() { }
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
错误信息:
错误 1 命名空间“Microsoft.Office.Tools.Word”中不存在类型或命名空间名称“Controls”(您是否缺少程序集引用?) C:\Users\root\Documents\Visual Studio 2010\项目\WordAddIn2\WordAddIn2\ThisAddIn.cs 14 45 WordAddIn2
【问题讨论】:
-
在您的问题中添加错误代码。
-
are you missing an assembly reference?- 你是吗? -
是的,你是。您需要添加 C:\Program Files\Reference Assemblies\Microsoft\VSTO40\v4.0.Framework\Microsoft.Office.Tools.Word.v4.0.Utilities.dll