Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. private void ThisAddIn_Startup(object sender, System.EventArgs e)
  2. {
  3. CommandBar cellbar = this.Application.CommandBars["Cell"];
  4. CommandBarButton button = (CommandBarButton) cellbar.FindControl(MsoControlType.msoControlButton, 0, "MYRIGHTCLICKMENU", Missing.Value, Missing.Value);
  5. if (button == null)
  6. {
  7. // add the button
  8. button = (CommandBarButton) cellbar.Controls.Add(MsoControlType.msoControlButton, Missing.Value, Missing.Value, cellbar.Controls.Count, true);
  9. button.Caption = "Refresh";
  10. button.BeginGroup = true;
  11. button.Tag = "MYRIGHTCLICKMENU";
  12. button.Click += new _CommandBarButtonEvents_ClickEventHandler(MyButton_Click);
  13. }
  14. }
  15.  
  16. private void MyButton_Click(CommandBarButton cmdBarbutton, ref bool cancel)
  17. {
  18. System.Windows.Forms.MessageBox.Show("MyButton was Clicked", "MyCOMAddin");
  19. }
  20.  
  21. //reset commandbars
  22. Application.CommandBars["Cell"].Reset();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement