VSTO WordアドインでCommandBarsオブジェクトのFindControlメソッドを使用して、コマンドバーオブジェクトのコードを他に取得しようとしていますコードは次のとおりです
private void WireContextMenu(string MenuID,string Tag, string ID, ref Office.CommandBarButton Control)
{
try
{
object missing = System.Type.Missing;
Control = (Office.CommandBarButton)this.Application.CommandBars[MenuID].FindControl((object)Office.MsoControlType.msoControlButton, ID, Tag, missing, missing);
if (Control == null)
{
Control = (Office.CommandBarButton)this.Application.CommandBars[MenuID].Controls.Add(Office.MsoControlType.msoControlButton, ID, missing, missing, missing);
Control.Caption = "Biolit Markup Selection";
Control.Tag = Tag;
}
Control.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.cb_Click);
}
catch (Exception Ex)
{
}
}
FindControl メソッドは Type Mismatch Exception (-2147352571) をスローしています。任意のアイデアは、単語の右クリック メニューに項目を追加し、それが既に存在する場合は追加しないようにする正しい方法です ありがとう