I am trying to create addin for excel that has a dropdown and a button.
I was successfully able to add button, but for some reason, I was not able to add dropdown to it.
Here is the code for button, this is calld in 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;
After doing some more research on google, I thought it was simpler to add ribbon designer and use that for adding more controls to the addin. But I am not able to view that ribbon on excel when I run the project.
I am totally lost what is the better solution for this.
Any help/link would be highly appreciated.
Thanks!!
I could use the same solution with Excel addin, by changing the line,
to
By removing the position, I could add as many controls on the addin, as I want.