Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void ThisAddIn_Startup(object sender, System.EventArgs e)
- {
- CommandBar cellbar = this.Application.CommandBars["Cell"];
- CommandBarButton button = (CommandBarButton) cellbar.FindControl(MsoControlType.msoControlButton, 0, "MYRIGHTCLICKMENU", Missing.Value, Missing.Value);
- if (button == null)
- {
- // add the button
- button = (CommandBarButton) cellbar.Controls.Add(MsoControlType.msoControlButton, Missing.Value, Missing.Value, cellbar.Controls.Count, true);
- button.Caption = "Refresh";
- button.BeginGroup = true;
- button.Tag = "MYRIGHTCLICKMENU";
- button.Click += new _CommandBarButtonEvents_ClickEventHandler(MyButton_Click);
- }
- }
- private void MyButton_Click(CommandBarButton cmdBarbutton, ref bool cancel)
- {
- System.Windows.Forms.MessageBox.Show("MyButton was Clicked", "MyCOMAddin");
- }
- //reset commandbars
- Application.CommandBars["Cell"].Reset();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement