CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Jun 2008
    Posts
    4

    Excel Addin Commandbar does not add Combobox

    All I need to do is add a simple combobox to a excel commandbar. Seem simple enough. Problem is that I cannot get it to go visible. I used Visual Studio 2008’s Addin wizard to create the project. This is the code:

    private void AddCommandBar()
    {
    Office.CommandBars cmdBars = (Office.CommandBars)excelApp.CommandBars;
    Office.CommandBar CommandBar = cmdBars.Add(cmdBarName, 0, false, true);

    Office.CommandBarComboBox oCombo;
    oCombo = (Office.CommandBarComboBox)CommandBar.Controls.Add(Office.MsoControlType.msoControlComboBox, Type.Missing, Type.Missing, Type.Missing, true);
    oCombo.Text = "Text";
    oCombo.Caption = "Caption";
    oCombo.AddItem("one", Type.Missing);
    oCombo.AddItem("two", Type.Missing);
    oCombo.Style = Office.MsoComboStyle.msoComboNormal;// msoComboLabel;
    oCombo.Visible = true;

    //oCombo.BeginGroup = true;
    Office._CommandBarComboBoxEvents_ChangeEventHandler oComboHandler = new Office._CommandBarComboBoxEvents_ChangeEventHandler(OnClick_ServerChange);
    oCombo.Change += oComboHandler;

    CommandBar.Visible = true;
    }


    Anybody know why my combobox does not want to show in Excel (I’m running Office 2007). Please HELP!!
    Last edited by dwventer; June 4th, 2008 at 12:42 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured