Excel.Application app; private void ThisAddIn_Startup(object sender, System.EventArgs e) { app = Globals.ThisAddIn.Application; Office.CommandBars bars = app.CommandBars; Office.CommandBar bar = bars["cell"]; //获取右键菜单项 bar.Reset(); Office.CommandBarControls controls = bar.Controls; Office.CommandBarButton newControl =(Office.CommandBarButton)controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true); newControl.Caption = "My test"; newControl.Click += NewControl_Click; } private void NewControl_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault) { System.Windows.Forms.MessageBox.Show("Test"); }