XLL+ Class Library (7.0)

Ribbon RunTag actions

RunTag action callbacks

The table below lists the RunTag action callbacks which can be used to trigger a macro from a ribbon control. See Supporting earlier Excel versions for more information about RunTag action callbacks.

Control OnAction callback Parameters
button OnActionButtonRunTag  
dropDown, gallery OnActionIndexedRunTag index, selectedItemId
checkBox, toggleButton OnActionToggleButtonRunTag pressed

Macro substitution

You can pass event information within the macro by using % symbols within the tag. The table below lists the event information that can be inserted, along with the method of CRibbonEvtParams that returns the equivalent information.

Symbol Value CRibbonEvtParams method
%c Control ID GetId
%i Item ID GetSelectedId
%n Item index GetIndex
%p Pressed GetPressed

Note that you can use multiple substitutions within a single tag.


The ribbon group defined below demonstrates the use of various macro substitutions. Note the use of single quotes for some of the tag attribute values; this allows us to put double-quotes around the string arguments.

<group id="TagGroup" label="RunTag callbacks"> 
  <buttonGroup id="StyleGroup"> 
    <button id="SG_Left" imageMso="AlignLeft" label="Left"  
            onAction="OnActionButtonRunTag" tag='SetStyle("%c")'/> 
    <button id="SG_Center" imageMso="AlignCenter" label="Center"  
            onAction="OnActionButtonRunTag" tag='SetStyle("%c")'/> 
    <button id="SG_Right" imageMso="AlignRight" label="Right"  
            onAction="OnActionButtonRunTag" tag='SetStyle("%c")'/> 
  <dropDown id="MyDropDown" label="DropDown" 
            onAction="OnActionIndexedRunTag" tag='SetStyle("%i")'> 
    <item id="Item0" label="Left" imageMso="AlignLeft"/> 
    <item id="Item1" label="Center" imageMso="AlignCenter"/> 
    <item id="Item2" label="Right" imageMso="AlignRight"/> 
  <separator id="Separator1" /> 
  <toggleButton id="Toggle" label="Toggle" imageMso="Bold" size="large" 
                onAction="OnActionToggleButtonRunTag" tag="SetBold(%p)"/> 

The table below lists the actual macros that will be invoked:

Control Item/State Macro
SG_Left   SetStyle("SG_Left")
SG_Center   SetStyle("SG_Center")
SG_Right   SetStyle("SG_Right")
MyDropDown Item0 SetStyle("Item0")
MyDropDown Item1 SetStyle("Item1")
MyDropDown Item2 SetStyle("Item2")
Toggle Pressed SetBold(TRUE)
Toggle Not pressed SetBold(FALSE)