[英]Multiple Instances of Word Document Ribbon button disable in Word Addin Project
我的任務是從給定的 Word 文檔創建一個新文檔,然后我只需要在新創建的 Word 文檔功能區中禁用自定義功能區按鈕。 這里不考慮活動文檔,因為當用戶切換它時它正在切換。
目前我無法從 C# 代碼中獲取新的 Word 實例功能區控件。 當我申請以下時,兩個文件都會受到影響。
CustomRibbon ribbon = Globals.Ribbons.CustomRibbon;
ribbon.button.Enabled = false;
這樣的事情應該可行,您必須找到一種方法來識別您的文檔
private void MyAddin_Startup(object sender, System.EventArgs a)
{
this.Application.DocumentChange += new ApplicationEvents4_DocumentChangeEventHandler(Application_DocumentChange);
}
private void Application_DocumentChange()
{
bool enableButton = false;
if(yourdocument) // put something here that checks the document you want the button to be enable in
{
enableButton = true;
}
CustomRibbon ribbon = Globals.Ribbons.CustomRibbon;
ribbon.button.Enabled = enableButton;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.