Consulting

Results 1 to 20 of 33

Thread: Ribbon - toggle button problems

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    May 2012
    Posts
    15
    Location

    Ribbon - toggle button problems

    Hi guys,

    I’m not sure if this can be done, but I am trying to create two toggle buttons in a custom ribbon tab and make it such that:

    1. When toggle button 1 is pressed, toggle button 2 is switched off
    2. When toggle button 2 is pressed toggle button 1 button is switched off and so forth

    My code is below and im using invalidatecontrol method to reset a button to the off state when the other is pressed.

    Is there a simple way of getting this to work?

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon startFromScratch="false">
    <tabs>
    <tab id="customTab" label="Custom Tab">
    <group id="customGroup" label="Custom Group">
    <toggleButton id="customButton1" label="Face 1" imageMso="HappyFace" size="large" onAction="Callback1" />
    <toggleButton id="customButton2" label="Face 2" imageMso="HappyFace" size="large" onAction="Callback2" />
    </group>
    </tab>
    </tabs>
    </ribbon>
    </customUI> 
    
    Dim PressedState As Boolean
    Public gobjRibbon As IRibbonUI
    
    Public Sub OnRibbonLoad(objRibbon As IRibbonUI)
    Set gobjRibbon = objRibbon
    End Sub
    Sub callback1(control As IRibbonControl, pressed As Boolean)
    MsgBox "Face 1 on - Face 2 off"
    gobjRibbon.InvalidateControl ("customButton2")
    End Sub
    
    Sub callback2(control As IRibbonControl, pressed As Boolean)
    MsgBox "Face 2 on - Face 1 off"
    gobjRibbon.InvalidateControl ("customButton1")
    End Sub
    Is there a simple way of getting this to work?

    Thanks.
    Last edited by Aussiebear; 04-25-2023 at 07:13 PM. Reason: Adjusted the code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •