Overview of the IRibbonControl Object
The IRibbonControl object is passed in most of the callbacks that are available for controls in the ribbon or Microsoft Office Backstage view, as well as the customizable menu items in Microsoft Outlook. The object is especially useful for Outlook developers because it provides an IRibbonControl.Context property that returns the related Outlook object to which the customization is applied and is about to be displayed.
IRibbonControl exposes the following properties.
|Context||Object||Returns an object that represents the window in which the custom ribbon is about to be displayed, or the related object to which the menu customization is applied and is about to be displayed. Read-only.|
|Id||String||Returns a string that represents the Id attribute for the control or custom menu item. Read-only.|
|Tag||String||Returns a string that represents the Tag attribute for the control or custom menu item. Read-only.|
When you write managed code, try to cast the object represented by IRibbonControl.Context to the corresponding Outlook object. For example, if you customize a ribbon in an inspector, cast the Inspector object. Then, if the cast succeeds, you can compare the Inspector object that is returned by IRibbonControl.Context to other inspector windows that are open. To determine the underlying item that is displayed in an inspector window, examine Inspector.CurrentItem. Because CurrentItem is an Object type, your code must cast the object to an appropriate item type such as MailItem or ContactItem.
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.