Sometimes Excel 2003 does not fires CommandBarButton's event.
I create CommandButton under CommandBarPopup of ActiveMenuBar in ThisAddIn_Startup
using following code:
CommandBarPopup menuItem = (CommandBarPopup)Application.CommandBars.ActiveMenuBar.Controls.Add(
MsoControlType.msoControlPopup, missing, missing, missing, true );
menuItem.Caption = "111";
CommandBarButton btnConnect_;
btnConnect_ = (CommandBarButton)menuItem.Controls.Add(
MsoControlType.msoControlButton, missing, missing, missing, missing );
btnConnect_.Click += new _CommandBarButtonEvents_ClickEventHandler( btnConnect_Click );
btnConnect_.Caption = "Connect";
The event handler is:
private void btnConnect_Click(CommandBarButton Ctrl, ref bool CancelDefault)
{
System.Windows.Forms.MessageBox.Show("1212");
}
So, when Excel starts it creates "111" menu and "Connect" button under it.
When I click "Connect" button nothing is happened. Sometimes it is faired
but next will might be non executable.
PS. Is raised unhandled exception will turn off event handler too