Original: VSTO adds its own menu item (WORD,EXCEL) for office already has a right-click menu
private void Addrightmenu ()
{
Microsoft.Office.Core.CommandBar mzbar = appword.commandbars["Text"]; The Word document already has the right-click menu text
Microsoft.Office.Core.CommandBar Mzbar = appexcel.commandbars["Cell"]; Excel document already has a right-click menu cell
Microsoft.Office.Core.CommandBarControls bars = mzbar.controls;
foreach (Microsoft.Office.Core.CommandBarControl Temp_contrl in bars)
{
String t = Temp_contrl. Tag;
Delete if it already exists
if (t = = "Test") {
Temp_contrl. Delete ();
}
}
Microsoft.Office.Core.CommandBarControl Comcontrol = bars. ADD (Microsoft.Office.Core.MsoControlType.msoControlButton, missing, missing, missing, true); Add your own menu items
Microsoft.Office.Core.CommandBarButton Combutton = Comcontrol as Microsoft.Office.Core.CommandBarButton;
if (Comcontrol! = null)
{
Combutton.tag = "Test";
combutton.caption = "Test";
Combutton.style = Microsoft.Office.Core.MsoButtonStyle.msoButtonIconAndCaption;
Combutton.click + = new Office._commandbarbuttonevents_clickeventhandler (Menucommand_click);
}
}
For Outlook and PPT Specific is unclear, is being verified in ...
VSTO adds its own menu item (WORD,EXCEL) for office already has a right-click menu