Modifying the Ribbon – Part 11

The history of posts on the Ribbon can be found at the Ribbon Example Table of Contents.

For this installment, I thought I would focus on exploring the button control in depth, explaining what each piece of XML does when building the ribbon control, and what types of values are permitted for each one. In a follow-up article, we'll discuss how to make these controls dynamic, but for now we'll just focus on a very static button in a custom group.

Beginning With Static Items

Whenever we are programming, it is helpful to understand what pieces of code are assigned to what properties of the object. The following is a list of all of the components that we can set for a button, and where they show up:

Base XML Markup

The framework for the XML Markup is fairly static, although we'll explore some minor modifications to it in the next section. For most purposes, however, it starts with a declaration of the schema, opening your Ribbon object, referring to (or creating) a tab, and referring to (or creating) a group. Within the group tag is where we will place all of our button (or other) controls. The XML below creates a new tab called "XLG" after the "View" tab, adds a group called "My Testing Tab" and puts the button there.

Rather than explain all the XML at this point, be aware that the code to create any control within the group should be surrounded by the open and close tags: "<" and "/>"

For our purposes, I have constructed the base XML we'll use, which should be added to an Excel file by using the CustomUI editor. I would suggest creating, saving and closing a new file for this (make it an xlsm file). Once done, open it in the CustomUI editor and paste in the following XML:

[xml]






Share:

Facebook
Twitter
LinkedIn

12 thoughts on “Modifying the Ribbon – Part 11

  1. An answer on the issues I'd raised on the showImage and showLabel tags related to large buttons. I had the chance to participate in a conference call with Microsoft last week, and was able to mention the issue of these tags being ignored when set to false with large buttons.

    Apparently, this was actually intentional... go figure that. (It wasn't the right forum to ask why, so that's the best I can do for you right now.)

    So if you do want to mimic showImage="false" or showLabel="false" on a large button, you'll need to use the workarounds that I discussed above.

    🙂

  2. Hi Ken,

    I was wondering if it is possible to hide or modify the lower section of the screen tip, the one under the horizontal line, with a "gear" icon and the name of the workbook? Showing the name of the underlying workbook does NOT make our Excel App look polished.

    Thanks,
    Neil

  3. Hi Neil,

    Unfortunately, no. We can't touch the workbook name, the gear, or even remove the F1 for help line. Quite irritating, that. 🙁

  4. Hi Alex,

    You've only really got two options. You can insert your tab before the home tab, which will activate it when the workbook opens (most of the time). The other option you have it using SendKeys to send the keystrokes to the application to activate the tabs.

    It would be nice if we could activate the tabs via the object model, but no so luck yet.

  5. Hi Ken,

    SendKeys worked like a charm for me, thanks!!!!
    I do have another question, maybe you have some idea on how to implement it. I am looking for a way to associate Ribbon icons (Office icons) with Command Buttons. Do you know how to do that?

    Thanks
    Alex

  6. Hi Alex,

    I'm not sure I quite follow... are you asking to use RibbonX images on ActiveX command buttons, Forms toolbox buttons, or as CommandBarButtons in earlier versions of Excel?

  7. Sorry for confusing the subject, I am asking for CommandButton control in MS Access. I'd like to use the images that are in the RibbonX library for a button on a Access form.

  8. Hi Alex,

    Honestly, I'd probably do this by taking a screen shot of the image using SnagIt (or some other capture software), save it to my hard drive, then link the picture by using the browse button.

    I'm certainly not saying that it couldn't be done via code, but I've never taken the time to try and do it for an Access button. You could look at the userform on this post to see how it is all linked up though: https://excelguru.ca/2007/05/05/identifying-your-imagemso-excel-word-powerpoint/ It may work into an answer for you. 🙂

  9. Great article and very helpful.

    I am wondering how to add a newline to the 'supertip' in order to break up the tip into a more easily read tip?

    In addition to the newlines, some of the built-in supertips include the use of images, I am wondering how this is achieved?

  10. Pingback: Ribbon button - showLabel attribute ignored

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Posts