Consulting

Results 1 to 20 of 33

Thread: Ribbon - toggle button problems

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,895
    Location
    You just need to use the getPressed callback and to include onLoad in your xmlns

    Option Explicit
    Public gobjRibbon As IRibbonUI
    Public B1 As Boolean, B2 As Boolean
     
    Public Sub OnRibbonLoad(objRibbon As IRibbonUI)
    Set gobjRibbon = objRibbon
    B1 = False
    B2 = False
    End Sub
     
    'Callback for customButton1 onAction
    Sub Pushed(control As IRibbonControl, pressed As Boolean)
    Select Case control.ID
        Case "customButton1"
            B1 = True
            B2 = False
        Case "customButton2"
            B1 = False
            B2 = True
    End Select
    gobjRibbon.Invalidate
    End Sub
    
    'Callback for customButton1 getPressed
    Sub UpOrDown(control As IRibbonControl, ByRef returnedVal)
    Select Case control.ID
        Case "customButton1"
            returnedVal = B1
        Case "customButton2"
            returnedVal = B2
    End Select
    End Sub
     
    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"onLoad="OnRibbonLoad" >
    <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="Pushed"getPressed="UpOrDown" />
    <toggleButton id="customButton2"label="Face 2"imageMso="HappyFace"size="large"onAction="Pushed"getPressed="UpOrDown" />
    </group>
    </tab>
    </tabs>
    </ribbon>
    </customUI> 
    
    Paul
    Attached Files Attached Files
    Last edited by Aussiebear; 04-25-2023 at 07:16 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
  •