Microsoft Office Tutorials and References
In Depth Information
Menus in Outlook
Let's write a program to create a menu item and call it Say Hello World .
// Defining new Menubar
private Office.CommandBar PacktOldMenuBar;
// Defining old Menubar
private Office.CommandBarPopup PacktNewMenuBar;
// Defining instance of button for menu item
private Office.CommandBarButton PacktButton1;
// Tag string for our Menu item
private string strMenuString = "Outlook AddIn #1";
private void ThisAddIn_Startup(object sender,
System.EventArgs e)
// Define the Old Menu Bar
PacktOldMenuBar = this.Application.ActiveExplorer().
// Define the new Menu Bar into the existing menu bar
PacktNewMenuBar = (Office.CommandBarPopup)PacktOldMenuBar.
missing, missing, missing, false);
//If PacktNewMenuBar not found then the code will add it
if (PacktNewMenuBar != null)
// Set caption for the Menu
PacktNewMenuBar.Caption = "Packt Menu Item 1";
// Tag string value passing
PacktNewMenuBar.Tag = strMenuString;
// Assigning button type
PacktButton1 = (Office.
msoControlButton, missing, missing, 1, true);
// Setting up the button style
PacktButton1.Style = Office.MsoButtonStyle.
// Set button caption
PacktButton1.Caption = "Say Hello World";
// Set the menu visible
PacktNewMenuBar.Visible = true;
Search JabSto ::

Custom Search