Skip to content
Pieter Geerkens edited this page Mar 7, 2019 · 3 revisions

Welcome to the PGSolutions.BetterRibbon wiki!

A better ribbon is now available - the way it was always meant to be delivered.

As this page undergoes initial construction, it will be mostly a bullet list of topics deemed interesting or enlightening about the project. Structure will follow later.

How many (repurposable) controls does your ribbon need?

A better ribbon provides the ability to dynamically, and easily, customize functionality, labels and descriptive text for controls at runtime; as each workbook acquires focus in turn. Here the Customizable Group of the Add-In Ribbon is hidden as a new workbook is opened.

Customizable Group hidden as new workbook opened

Opening up the Single Button Demo workbook shows the Customizable Group with one activated button:

Customizable Group after opening Single Button demo.

Opening up the full Ribbon Demonstration workbook now shows three additional controls; a toggle button and two more (action) buttons.

The remaining (deactivated and normally hidden for this workbook) controls of the Customizable Group are now shown by pressing the toggle button:

Generic callbacks simplify Ribbon construction

Traditional ribbon construction relies on a plethora of unique magic strings, embedded in the XML ribbon specification, that must then be tracked and documented through the project lifetime. A better way is to employ generic callbacks for all controls, with dispatch to the control managed by dictionary lookup at runtime. The only magic string for each control becomes its name, the ControlId string. All other callbacks are just to a routine of the same name as the callback XML tag.

        <mso:button id="CurrentProjectButtonPG" getVisible="getVisible" getEnabled="getEnabled"
                getLabel="getLabel" getKeytip="getKeytip" getScreentip="getScreentip" getSupertip="getSupertip"
                getSize="getSize" getShowImage="getShowImage" getShowLabel="getShowLabel" getImage="getImage"
                onAction="onAction"
           />
    </mso:box>
</mso:group>
<mso:group id="CustomizableGroup" getVisible="getVisible"
           getLabel="getLabel" getKeytip="getKeytip" getScreentip="getScreentip" getSupertip="getSupertip">
    <mso:toggleButton id="CustomVbaToggle" getImage="getImage"
              getLabel="getLabel" getKeytip="getKeytip" getScreentip="getScreentip" getSupertip="getSupertip"
              onAction="onActionToggle" getVisible="getVisible" getEnabled="getEnabled" getPressed="getPressed"
              getSize="getSize" getShowImage="getShowImage" getShowLabel="getShowLabel"
         />
    <mso:box id="CustomVbaBox1" boxStyle="vertical" visible="true" >
        <mso:checkBox id="CustomVbaCheckBox1"
                  getLabel="getLabel" getKeytip="getKeytip" getScreentip="getScreentip" getSupertip="getSupertip"
                  onAction="onActionToggle" getVisible="getVisible" getEnabled="getEnabled" getPressed="getPressed"
         />