Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I am using VSTO SE for excel development. I am trying to add menu items to context menu. Well, I can add it but some how the menu item loses the click event when it is clicked once i.e. click event handler is invoked only once. Here is the code fragment that adds menu item, Office.CommandBarPopup Ctrl1; Office.CommandBarButton Ctrl2, Ctrl3; Ctrl1 = (Office.CommandBarPopup)Application.CommandBars["Cell"].Controls.Add(Office.MsoControlType.msoControlPopu p, 1, null, 1, true); Ctrl1.Caption = "Menu Item"; Ctrl2 = (Office.CommandBarButton)Ctrl1.Controls.Add(Office .MsoControlType.msoControlButton, 1, null, 1, true); Ctrl2.Visible = true; Ctrl2.Caption = "C# Test Button 1"; Ctrl2.Tag = "AddinTag1"; Ctrl2.Click += new Office._CommandBarButtonEvents_ClickEventHandler(t his.moBtn_Click); Ctrl3 = (Office.CommandBarButton)Ctrl1.Controls.Add(Office .MsoControlType.msoControlButton, 1, null, 1, true); Ctrl3.Visible = true; Ctrl3.Caption = "C# Test Button 2"; Ctrl3.Tag = "AddinTag2"; Ctrl3.Click += new Office._CommandBarButtonEvents_ClickEventHandler(t his.moBtn_Click1); These are event handlers, private void moBtn_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault) { MessageBox.Show(Ctrl.Tag); Trace.Write("moBtn_Click - " + Ctrl.Tag); } private void moBtn_Click1(Office.CommandBarButton Ctrl, ref bool CancelDefault) { MessageBox.Show(Ctrl.Tag); Trace.Write("moBtn_Click - " + Ctrl.Tag); } Can anybody tell me what is happening here? Thanks in advance |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Combobox - can't get click event to run for first item in the list | Excel Programming | |||
Click Event taking time | Excel Programming | |||
OnTime event not firing in Workbook_Open event procedure | Excel Programming | |||
Triggering click event of a menu in vba | Excel Programming | |||
Triggering click event of a menu in vba | Excel Programming |