toggleButton

In the object model this is RibbonToggleButton.
A toggleButton is a clickable item that toggles between being pressed and not pressed.
There is a Click event that is raised when the user clicks the togglebutton

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" 
          onLoad="Ribbon_OnLoad">
  <ribbon startFromScratch="false">
    <tabs>
      <tab id="CustomTab"
           label="Toggle Letter/A4"
           insertAfterMso="TabHome">
        <group id="Group1"
               label="Toggle Paper Size">
          <toggleButton id="MyToggleButton1"
                        imageMso="ObjectNudgeRight"
                        label="Letter Paper Size"
                        size="large"
                        onAction="ToggleButton1_OnAction"
                        getPressed="ToggleButton1_OnGetPressed"/>
          <separator id="Separator1"/>
          <toggleButton id="MyToggleButton2"
                        imageMso="ObjectNudgeLeft"
                        label="A4 Paper Size"
                        size="large"
                        onAction="ToggleButton2_OnAction"
                        getPressed="ToggleButton2_OnGetPressed"/>
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

Attributes (Properties)

description(Description)
enabled"true" | "false"
id 
idMso(OfficeImageID)
idQ 
image 
imageMso 
insertAfterMso 
insertAfterQ 
insertBeforeMso 
insertBeforeQ 
keytip 
label(Label)
screentip(ScreenTip)
showImage"true" | "false"
showLabel(ShowLabel) "true" | "false"
size(ControlSize)
supertip(SuperTip)
tag(Tag)
visible"true" | "false"
 (Checked)

Callbacks

onActionToggleButton_OnAction
getDescriptionToggleButton_OnGetDescription
getEnabledToggleButton_OnGetEnabled
getImageToggleButton_OnGetImage
getImageMsoToggleButton_On
getKeytipToggleButton_OnGetKeytip
getLabelToggleButton_OnGetLabel
getPressedToggleButton_OnGetPressed
getScreentipToggleButton_OnGetScreentip
getShowImageToggleButton_OnGetShowImage
getShowLabelToggleButton_OnGetShowLabel
getSizeToggleButton_On
getSupertipToggleButton_OnGetSupertip
getVisibleToggleButton_OnGetVisible

' VBA
Public Sub ToggleButton_OnAction( _
   ByRef control As Office.IRibbonControl, _
   ByRef isPressed As Boolean)

End Sub

' C# Equivalent
public void ToggleButton_OnAction(
   Microsoft.Office.Core.IRibbonControl control,
   bool pressed)
{
}

' VBA
Public Sub ToggleButton_OnGetDescription( _
   ByRef control As Office.IRibbonControl, _
   ByRef ReturnedValue As Variant)

End Sub

' VBA
Public Sub ToggleButton_OnGetEnabled( _
   ByRef control As Office.IRibbonControl, _
   ByRef ReturnedValue As Variant)

End Sub

' VBA
Public Sub ToggleButton_OnGetImage( _
   ByRef control As Office.IRibbonControl, _
   ByRef ReturnedValue As Variant)

End Sub

' VBA
Public Sub ToggleButton_OnGetKeytip( _
   ByRef control As Office.IRibbonControl, _
   ByRef ReturnedValue As Variant)

End Sub

' VBA
Public Sub ToggleButton_OnGetLabel( _
   ByRef control As Office.IRibbonControl, _
   ByRef ReturnedValue As Variant)

End Sub

' VBA
Public Sub ToggleButton_OnGetPressed( _
   ByRef control As Office.IRibbonControl, _
   ByRef ReturnedValue As Variant)

End Sub

' VBA
Public Sub ToggleButton_OnGetScreentip( _
   ByRef control As Office.IRibbonControl, _
   ByRef ReturnedValue As Variant)

End Sub

' VBA
Public Sub ToggleButton_OnGetShowImage( _
   ByRef control As Office.IRibbonControl, _
   ByRef ReturnedValue As Variant)

End Sub

' VBA
Public Sub ToggleButton_OnGetShowLabel( _
   ByRef control As Office.IRibbonControl, _
   ByRef ReturnedValue As Variant)

End Sub

' VBA
Public Sub ToggleButton_OnGetSupertip( _
   ByRef control As Office.IRibbonControl, _
   ByRef ReturnedValue As Variant)

End Sub

' VBA
Public Sub ToggleButton_OnGetVisible( _
   ByRef control As Office.IRibbonControl, _
   ByRef ReturnedValue As Variant)

End Sub


Public goRibbon As IRibbonUI 
Public gbToggle1Pressed As Boolean
Public gbToggle2Pressed As Boolean

Public Sub Ribbon_OnLoad(ribbon As IRibbonUI)
   goRibbon = ribbon
End Sub

Public Sub ToggleButton1_OnAction(control As IRibbonControl, pressed As Boolean)
   gbToggle1Pressed = True
   gbToggle2Pressed = False
   Call MsgBox("format Letter")
End Sub

Public Sub ToggleButton1_OnGetPressed(control As IRibbonControl, ByRef returnedVal)
   returnedVal = gbToggle1Pressed
   goRibbon.Invalidate
End Sub

Public Sub ToggleButton2_OnAction(control As IRibbonControl, pressed As Boolean)
   gbToggle1Pressed = False
   gbToggle2Pressed = True
   Call MsgBox("format A4")
End Sub

Public Sub ToggleButton2_OnGetPressed(control As IRibbonControl, ByRef returnedVal)
   returnedVal = gbToggle2Pressed
   goRibbon.Invalidate
End Sub


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext