Share via


IRibbonControl.Tag Property

Used to store arbitrary strings and fetch them at runtime. Read-only

Namespace:  Microsoft.Office.Core
Assembly:  office (in office.dll)

Syntax

'Declaration
ReadOnly Property Tag As String
    Get
'Usage
Dim instance As IRibbonControl
Dim value As String

value = instance.Tag
string Tag { get; }

Property Value

Type: System.String
String

Remarks

Normally you can distinguish between controls in a Ribbon user interface XML customization file using the Id property. However, there are restrictions on what IDs can contain (no non-alphanumeric characters, and they must all be unique). The Tag property doesn’t have these restrictions and so it can be used in the following situations, where ID doesn’t work:

  • If you need to store a special string with your control such as a filename. For example: tag=”C:\path\file.xlsm.”

  • If you want multiple controls to be treated the same way by your callback procedures, but you don’t want to maintain a list of all of their IDs (which must be unique). For example, you could have buttons on different tabs on the Ribbon, all with tag=”blue”, and then just check the Tag property instead of the ID property when perfroming some common action.

Examples

In the XML used to customize the Ribbon user interface, you can set a tag as follows. When the MyFunction action is called, you can read the Tag property, which will be equal to “some string”.

<button id=”mybutton” tag=”some string” onAction=”MyFunction”/>

See Also

Reference

IRibbonControl Interface

IRibbonControl Members

Microsoft.Office.Core Namespace