Resting Anchor

The Anchorage

Personal website of Gregory K. Maxey, Commander USN (Retired)

Ribbon Gallery Control
(A Microsoft Word Help & Tip page by Gregory K. Maxey)


The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.

Click to acces PayPal Verification Service Click to acces PayPal Verification Service

However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.

If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!

The purpose of this Microsoft Word Help & Microsoft Word Tips page is to publish and provide  examples of a functional ribbon gallery controls.

The gallery control is a neat new control in the Office 2007/2010 user interface (UI). You can use it to save space on the ribbon by arranging other controls in the gallery, and most significantly it provides a means to present user options graphically on the ribbon.

The Styles group on the Home tab is one example of a built-in gallery control. The gallery presents the available styles in the style set followed by several button controls.

ribbon gallery control 1

The illustrations presented in this tips page are from a Word template add-in I created for the purpose of testing and demonstrating the use of the gallery control. In addition to gallery controls, the add-in contains and provides a demonstration of:

The custom ribbon created with the add-in appears as shown below:

ribbon gallery conrol 2

You can download the template add-in which contains the associated ribbon, custom XML and VBA callbacks using this link: Gallery Control Demonstration

Site Note icon For more on template add-ins and how to load them, see: Organizing Your Macros/Template Add-ins at: Installing Macros

Custom Gallery Controls

On the surface a gallery control looks very much like a menu control. In my Ribbon Menu Controls tips page you can learn how to use menus and splitButtons as a container to organize and arrange other controls.

Much like a menu control, the gallery control is simply a container for its child elements. The child elements for a gallery are the gallery "items" and button controls. With some limitations (no formatting controls), a gallery can also be used as a container to arrange other controls.

A distinction with the gallery control is that the gallery items can be arranged horizontally or in multiple columns and rows vice the vertical arrangement seen in menus.

A good example of employing a gallery control for arranging other controls is shown in my: Outlook Interoperability.

Static Macro Gallery

In the "Static Macro Gallery" shown below, I used a horizontal (5 column x 1 row) gallery to display gallery item controls for five handy macros that I included with this template followed by a single button control to view the Visual Basic Editor. This control was constructed using only the static attributes of the control.

ribbon gallery control 3

Dynamic Macro Gallery

The "Dynamic Gallery" looks and functions similarly to the static gallery. This control was constructed using the dynamic attributes of the gallery control. Rather than list just the 5 handy macros contained in the previous example, I knew that I had some macros in a target VBA Project Module, five specifically, but I didn't want to go to the trouble to find out just how many or their names.

Using dynamic attributes of the control we can query the target Project Module to determine how many and what labels to apply to any qualified macros contained in the project. If macros are later added or deleted from the project, the control will update to reflect these changes when the template is saved and then reopened. Since "how many" is an unknown and could be a large number, I used a 3 column gallery and set the size attribute to the smaller "normal" control size.

Site Note IconRemember: A static attribute is defined in the RibbonXML e.g., size="normal" where a dynamic attribute is defined by a VBA callback e.g., getSize=RibbonControl.GetSize, where a procedure in the VBA project will return the size attribute "normal" or "large."

ribbon gallery contol 4

The Static and Dynamic Macro galleries were presented first just to show you how a basic gallery can be constructed using static and dynamic attributes. Other than showing some plain old controls horizontally across the screen or grouped in columns and rows, there really wasn't anything these galleries offered over a menu.

The great feature of a gallery is that it can display user options graphically.

Signature Gallery

The "Signature" gallery holds a collection of signatures of famous men and a few whimsical characters that can be inserted in a document.

Site Note IconNote: For more on using images and labels with ribbon controls see my: Ribbon Images & Labels Part I.

ribbon gallery control

Photo Gallery

As a final functional example I have included the group "Photo Gallery." In addition to a gallery control this group provides examples of three controls that I haven't used before the "editBox," "checkBox" and "dialogBoxLauncher."

ribbon gallery control 6

ribbon gallery control 7

ribbon gallery control 8

Site Note IconNotes:
    1. The VBA call back for the Dynamic Gallery requires access to the VBA project code module in this template. As project code modules in template Add-Ins are "not viewable," an extra process is required in order to populate the dynamicMenu with a list of project module qualifying procedures if the template is loaded as a template add-in.amiwrong icon This step involves temporarily opening the template as a document, extracting the data from the project, and then closing the document. This results in a slight processing delay as the template is loaded.

    2. The controls in this template call macro procedures located in the template. To facilitate their use set the following user options Word>Options>Trust Center>Trust Center Settings and check "Trust access to VBA project module."

    3. For an introduction to ribbon customization and lots of information on other controls including static and dynamic attributes, parent and child controls, and VBA callbacks see my: Customize the Ribbon

That's it! I hope you have found this tips page useful and informative.



Click to acces PayPal Verification Service Click to acces PayPal Verification Service

Do you want to make a payment for consulting work or donate to help support this site?

PayPal is a safe, easy way to pay online.

Use the appropriate currency "Donate" button to make a payment or donation.

Search my site or the web using Google Search Engine

Google Search Logo