Share via


RibbonOfficeMenu Class (2007 System)

Provides access to controls that you add to the Microsoft Office Menu.

Namespace:  Microsoft.Office.Tools.Ribbon
Assembly:  Microsoft.Office.Tools.Common.v9.0 (in Microsoft.Office.Tools.Common.v9.0.dll)

Syntax

'Declaration
Public NotInheritable Class RibbonOfficeMenu _
    Inherits RibbonComponent
'Usage
Dim instance As RibbonOfficeMenu
public sealed class RibbonOfficeMenu : RibbonComponent
public ref class RibbonOfficeMenu sealed : public RibbonComponent
public final class RibbonOfficeMenu extends RibbonComponent

Remarks

When you add a Ribbon (Visual Designer) item to your project, Visual Studio Tools for Office automatically assigns a new RibbonOfficeMenu object to the OfficeMenu property of the generated OfficeRibbon class. Use this object to add new controls to the Microsoft Office Menu at run time, or to access controls that you added to the Microsoft Office Menu.

You can add controls at run time, but only before the Ribbon is loaded. Create an instance of the control, and then add the new control to the Items collection. For more information, see Ribbon Object Model Overview.

Examples

The following example iterates through the custom controls on the Ribbon Office menu and displays their name. To run this code example, you must first perform the following steps:

  1. Add a Ribbon (Visual Designer) item to a Visual Studio Tools for Office project.

  2. Add a button to the Microsoft Office Button.

  3. Set the (Name) property of the button to myOfficeMenuButton.

  4. Set the PositionType property to AfterOfficeID under the Position property.

  5. Set the OfficeID property to FilePrintMenu under the Position property.

Private Sub ListOfficeRibbonCustomControls()
    System.Windows.Forms.MessageBox.Show( _
            "Listing all Office Menu custom controls...")
    For Each control As RibbonComponent In Globals.Ribbons.Ribbon1.OfficeMenu.Items
        System.Windows.Forms.MessageBox.Show("Control name: " + control.Name)
    Next 
End Sub
private void ListOfficeRibbonCustomControls()
{
    System.Windows.Forms.MessageBox.Show(
        "Listing all Office Menu custom controls...");
    foreach (RibbonComponent control in Globals.Ribbons.Ribbon1.OfficeMenu.Items)
    {
        System.Windows.Forms.MessageBox.Show("Control name: " + control.Name);
    }
}

Inheritance Hierarchy

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      Microsoft.Office.Tools.Ribbon.RibbonComponent
        Microsoft.Office.Tools.Ribbon.RibbonOfficeMenu

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

RibbonOfficeMenu Members

Microsoft.Office.Tools.Ribbon Namespace

Other Resources

How to: Customize the Microsoft Office Menu

Ribbon Object Model Overview