Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm using Visual Studio for office to create an Excel Addin. I've created a
sample menu, with 2 methods. If I select a menu item, it displays my dialog box. After I close it my menu will not display again. It won't drop down when clicked on. Do you know why? (BTW, using C# not VB) If you click choice1 or choice2, then you are done, can't do it twice. Code below: private void ThisAddIn_Startup(object sender, System.EventArgs e) { #region VSTO generated code this.Application = (Excel.Application)Microsoft.Office.Tools.Excel.Ex celLocale1033Proxy.Wrap(typeof(Excel.Application), this.Application); #endregion CheckIfMenuBarExists(); AddMenuBar(); } // Create the menu, if it does not exist. private void AddMenuBar() { try { Office.CommandBarButton menuCommand; Office.CommandBarPopup cmdBarControl = null; Office.CommandBar menubar = (Office.CommandBar)Application.CommandBars.ActiveM enuBar; int controlCount = menubar.Controls.Count; string menuCaption = "&Stockwatch Quotes"; // Add the menu. cmdBarControl = (Office.CommandBarPopup)menubar.Controls.Add( Office.MsoControlType.msoControlPopup, missing, missing, controlCount, true); if (cmdBarControl != null) { cmdBarControl.Caption = menuCaption; Office.CommandBarButton m1, m2; // Add the menu command. m1 = (Office.CommandBarButton)cmdBarControl.Controls.Ad d( Office.MsoControlType.msoControlButton, missing, missing, missing, true); m1.Caption = "&Choice 1..."; m1.Tag = "choice1"; m1.FaceId = 65; m1.Click += new Microsoft.Office.Core._CommandBarButtonEvents_Clic kEventHandler( choice1_Click); m2 = (Office.CommandBarButton)cmdBarControl.Controls.Ad d( Office.MsoControlType.msoControlButton, missing, missing, missing, true); m2.Caption = "&Choice 2..."; m2.Tag = "choice2"; m2.FaceId = 65; m2.Click += new Microsoft.Office.Core._CommandBarButtonEvents_Clic kEventHandler( choice2_Click); } } catch (Exception e) { MessageBox.Show(e.Message); } } private void choice1_Click(Microsoft.Office.Core.CommandBarButt on Ctrl, ref bool CancelDefault) { MessageBox.Show("Choice 1"); CancelDefault = false; } private void choice2_Click(Microsoft.Office.Core.CommandBarButt on Ctrl, ref bool CancelDefault) { MessageBox.Show("Choice 2"); CancelDefault = false; } |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to add right-click menu in excel. | Excel Discussion (Misc queries) | |||
How to add right-click menu in excel. | Excel Programming | |||
right click menu excel | New Users to Excel | |||
custom right click menu | Excel Programming | |||
Custom Menu return to Excel Menu upon Closing | Excel Programming |