I am trying to create my own toolbar and menu items inside my VS.NET =
AddIn as follows:
Office.CommandBars commandBars =3D applicationObject.CommandBars;=20
try
{
m_CmdBar =3D (Office.CommandBar)commandBars["Palantir Fellowship"];
string test =3D m_CmdBar.Name; //this will throw an ArgumentException if =
the bar doesn't exist
}
catch(Exception)
{
m_CmdBar =3D null;
}
if ( m_CmdBar =3D=3D null )
{
m_CmdBar =3D applicationObject.Commands.AddCommandBar("Palantir =
Fellowship", EnvDTE.vsCommandBarType.vsCommandBarTypeToolbar, null, 1) =
as Office.CommandBar;
}=20
m_CmdBar.Position =3D Office.MsoBarPosition.msoBarTop;
m_CmdBar.Visible =3D true;=20
// add a button on the toolbar for the apply changes
try
{
m_ApplyChangesBtn =3D m_CmdBar.Controls["Apply Changes to =
Fellowship..."] as Office.CommandBarButton;
}
catch{}
if ( m_ApplyChangesBtn =3D=3D null )
{
m_ApplyChangesBtn =3D AddButtonToToolbar(m_CmdBar, "Apply Changes to =
Fellowship...", "Apply Changes to Fellowship...", "OnApplyChangesClick", =
"ApplyChanges", true, true, true, false);
}
// Add a menu item to Build Menu to apply changes
Office.CommandBar cmdBar =3D commandBars["MenuBar"];
m_BuildMenu =3D =
cmdBar.FindControl(Office.MsoControlType.msoControlButtonPopup, =
cmdBar.Controls["Build"],=20
Missing.Value, Missing.Value, false) as Office.CommandBarPopup;
m_ApplyChangesMenuItem =3D AddButtonToMenu(m_BuildMenu, "ApplyChanges", =
"Apply Changes to Fellowship...", "OnApplyChangesClick", true, true, =
true, false);=20