dwventer
June 4th, 2008, 12:39 PM
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!!
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!!