private Office.CommandBar commandBar;
private Office.CommandBarButton firstButton;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
AddToolbar();
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
private void AddToolbar()
{
if (commandBar == null)
{
commandBar = Application.CommandBars.Add("Review", 1, missing, true);
}
try
{
firstButton = (Office.CommandBarButton)commandBar.Controls.Add(1, missing, missing, missing, missing);
firstButton.Style = Office.MsoButtonStyle.msoButtonCaption;
firstButton.Caption = "Review All";
firstButton.Tag = "Review All";
firstButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonClick);
commandBar.Visible = true;
}
catch (ArgumentException e)
{
MessageBox.Show(e.Message);
}
}
private void ButtonClick(Office.CommandBarButton ctrl, ref bool cancel)
{
MessageBox.Show("You clicked: " + ctrl.Caption);
}
url:http://msdn.microsoft.com/zh-cn/library/scff9c7c%28v=VS.80%29.aspx#CommunityContent