在vs2010中的Excel插件

我正在尝试为有下拉和button的excel创build插件。

我成功地添加了button,但由于某种原因,我无法添加下拉菜单。

这里是button的代码,这是在ThisAddIn_startup calld:

try { _commandBar = Application.CommandBars["commandBar"]; _commandBar.Delete(); } catch (ArgumentException e) { } // Add a commandbar named Test. _commandBar = Application.CommandBars.Add("button1", Office.MsoBarPosition.msoBarRight, missing, true); // Add a button to the command bar and an event handler. _firstButton = (Office.CommandBarButton)_commandBar.Controls.Add( Office.MsoControlType.msoControlButton, missing, missing, missing, missing); _firstButton.Style = Office.MsoButtonStyle.msoButtonCaption; _firstButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(firstButton_ButtonClick); _commandBar.Visible = true; 

在对Google进行了一些更多的研究之后,我认为添加Ribbondevise器会更简单,并使用它来为插件添加更多的控件。 但是当我运行这个项目时,我不能在excel上看到这个function区。

我完全失去了什么更好的解决scheme。

任何帮助/链接将不胜感激。

谢谢!!

如果您正在运行Excel 2007,则可以通过转到主Excel菜单(左上方的大button)来激活开发人员function区,然后在该对话框的右下方有一个Excel选项button。 从那里开始stream行,并selectfunction区中的Show Developer标签。

我可以使用与Excel插件相同的解决scheme,通过更改行,

  _commandBar = Application.CommandBars.Add("button1", Office.MsoBarPosition.msoBarRight, missing, true); 

 _commandBar = Application.CommandBars.Add("button1", missing, missing, true); 

通过删除位置,我可以添加尽可能多的控制插件,如我所愿。