我正在閱讀tutorial on how to use control blocks to manipulate document in word。
問題陳述:c#office開發:Microsoft.Office.Tools.Word.Controls.Button給出錯誤
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」不存在(是否缺少程序集引用? )C:\用戶\ ROOT \文檔\ Visual Studio 2010的\項目\ WordAddIn2 \ WordAddIn2 \ ThisAddIn.cs 14 45 WordAddIn2
將錯誤代碼添加到您的問題。 – 2014-09-26 09:10:52
'你錯過了一個程序集參考嗎?' - 是嗎? – 2014-09-26 11:41:48
是的,你是。您需要添加C:\ Program Files \ Reference Assemblies \ Microsoft \ VSTO40 \ v4.0.Framework \ Microsoft.Office.Tools.Word.v4.0.Utilities.dll – 2014-09-26 11:51:42