2016-12-24 7 views
0

カスタムUIを使用してExcelのセルの右クリックメニューでいくつかのオプションを作成しようとしています。ここ はXMLExcelでカスタムコンテキストメニューが表示されない(VSTO C#)

<?xml version="1.0" encoding="UTF-8"?> 
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load"> 
    <ribbon> 
    </ribbon> 
    <contextMenus> 
    <contextMenu idMso="ContextMenuText"> 
     <button id="mybutton" onAction="ShowMessageClick" getLabel="GetSynchronisationLabel"/> 

    </contextMenu> 
    </contextMenus> 
</customUI> 

そして、ここでは、私はこのコードを使用して追加ThisAddin.cs

namespace DemoAddin 
{ 
    public partial class ThisAddIn 
    { 


     public string GetSynchronisationLabel(Office.IRibbonControl control) 
     { 
      return "Synchronize"; 
     } 

     public void ShowMessageClick(Office.IRibbonControl control) 
     { 
      MessageBox.Show("You've clicked the synchronize context menu item", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); 
     } 

     protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject() 
     { 
      return new Ribbon2(); 

     } 
     private void ThisAddIn_Startup(object sender, System.EventArgs e) 
     { 



     } 

     private void ThisAddIn_Shutdown(object sender, System.EventArgs e) 
     { 
     } 

     #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 
    } 
} 

オプションがコンテキストメニューに表示されていないです。単に "ContextMenuCell" にContextMenuTextからコンテキストメニューのidMsoを変更

答えて

0

は、問題を解決しました。

<contextMenus> 
    <contextMenu idMso="ContextMenuCell"> 
     <button id="mybutton" onAction="ShowMessageClick" getLabel="GetSynchronisationLabel"/> 

    </contextMenu> 
    </contextMenus> 
関連する問題