2011-07-26 26 views
1

我想創建一個有下拉式和按鈕的excel插件。vs2010中的Excel插件

我成功地添加了按鈕,但由於某種原因,我無法將其添加到下拉菜單中。

這裏是按鈕的代碼,這是calld在ThisAddIn_startup:

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; 

在谷歌做一些更多的研究後,我認爲這是簡單的添加功能區設計和使用,添加多個控件添加到加入。但是當我運行該項目時,我無法在excel上查看該功能區。

我完全失去了什麼是更好的解決方案。

任何幫助/鏈接將不勝感激。

謝謝!

回答

0

我可以通過改變線路上使用與Excel加載項相同的解決方案,

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

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

通過去除的位置,我可以添加的插件儘可能多的控件,我想要。

0

如果您正在運行Excel 2007,您可以通過轉到主Excel菜單(左上方的大按鈕)來激活開發人員功能區,然後在該對話框的右下方有一個Excel選項按鈕。從那裏開始流行並選擇功能區中的Show Developer標籤。

+0

我試過了,它不起作用 – genericuser

+0

它不顯示開發人員功能區選項卡,或該選項不存在? – James

+0

選項wasnt there .. – genericuser