Search code examples
xmlms-officeribbonribbonx

Can't add ToggleButton to custom Ribbon


Using the excellent Office RibbonX Editor, I've created a custom tab for the Ribbon in Word. I used code like this to add existing commands to it:

        <button idMso="FileSave" />
        <button idMso="FileSaveAs" />
        <button idMso="Bold" />

The first two icons appear as desired, and they work correctly. But the "Bold" button does not appear, neither the icon nor the label. I determined that this happens only for ToggleButtons such as "Bullets" or "Superscript".


Solution

  • The correct term for a toggle button is

    <toggleButton
    

    as can be seen in the following xml which rebuilds the Paragraph tab in Word after I've made the original not visible

    <!-- Recreate the portions of the Paragraph tab that we actually need -->
                <group 
                    id="Home.Paragraphs" 
                    label="Paragraph" 
                    getVisible="RibbonCallbacksForVisibility.getVisible" 
                    insertBeforeMso="GroupEditing">
    
                    <box 
                        id="Home.Paragraph.Status"
                        boxStyle="horizontal">
                        <buttonGroup 
                            id="Home.Paragraph.Alignment">
                            <toggleButton idMso="AlignLeft"/>
                            <toggleButton idMso="AlignCenter"/>
                            <toggleButton idMso="AlignRight"/>
                            <toggleButton idMso="AlignJustify"/>    
                        </buttonGroup>
    
                        <buttonGroup 
                            id="Home.Paragraph.Marks"
                            visible="true">
                            <toggleButton idMso="ParagraphMarks"/>
                        </buttonGroup>
    
                    </box>
    
                    <box 
                        id="ParagraphIndent"
                        boxStyle="horizontal">
                        <button idMso="IndentDecreaseWord"/>
                        <button idMso="IndentIncreaseWord"/>
                    </box>
    
                    <box 
                        id = "ParagraphOther"
                        boxStyle="horizontal">
                        <gallery idMso="LineSpacingGallery"/>
                        <button idMso="SortDialogClassic"/>
                    </box>
    
                    <dialogBoxLauncher>
                        <button idMso="ParagraphDialog"/>
                    </dialogBoxLauncher>
    
                </group>