LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Cannot click twice on custom menu in Excel

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add right-click menu in excel. oioioi Excel Discussion (Misc queries) 3 September 13th 05 05:45 PM
How to add right-click menu in excel. oioioi Excel Programming 2 September 13th 05 04:40 PM
right click menu excel Jo Vercauteren New Users to Excel 1 May 3rd 05 09:34 PM
custom right click menu Father of 7 Excel Programming 1 January 27th 05 01:43 PM
Custom Menu return to Excel Menu upon Closing VetcalcReport Excel Programming 2 August 2nd 04 02:59 PM


All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"