Using getSize with RibbonX buttons

A friend just asked for some help with making a getSize callback work with some buttons. I figured this should be an easy one, and dove into the RibbonX book to check the table on page 172. Aha! There it is in the middle of the table:

Static Attribute Dynamic Attribute Allowed Values Default Value VBA Callback Signature For Dynamic Attribute
size getSize normal, large normal Sub GetSize (Control as IRibbonControl, ByRef returnedVal

So I whipped up a quick example to prove it out and… wtf? I started getting an error message:

Interesting… it returned a value that could not be converted to the expected type. What the heck is that about?

When you set up your XML code, you use normal or large in the code. So far as I know, they are the only allowed values, although I can’t say I tested that. What I did test, however is both normal and large in VBA callbacks. Both return the error listed above.

Interestingly enough, I decided to try passing a value of 0 or 1 to the callback via VBA and it worked! So then I gave it a whirl with true and false. Likewise, it worked.

So it looks like, in order to use a getSize callback with a button, you actually need to pass one of the following to the callback:

For

Use

Either

Or

normal

0

False

large

1

True

Just in case anyone wants to have a play with this, I’ve also attached a workbook here: getsize.zip. It also shows how to use getLabel on a tab, as well as getImage on a button. (It’s in a zip file, so you’ll need to unzip it first as my blog won’t accept xlsm uploads.)

5 thoughts on “Using getSize with RibbonX buttons

  1. Apart from being dangerously inconsistent, this is freaking non-intuitive. True or False? True or False with regards to what, the default.

    Have you tried this on 2010 Ken? What’s the odds that large and normal work there, and 0, 1 don’t?

  2. You know, Bob, I haven’t no. I’d expect that the 2007 stuff would work consistently in 2010, but if you used the new 2010 namespace it could go either way. So far I haven’t been able to make anything work with the 2010 namespace yet…

  3. Pingback: Excel Do, Dynamic Does

  4. “Have you tried this on 2010 Ken? What’s the odds that large and normal work there, and 0, 1 don’t?”

    I realize this is an old thread but since I recently had to code something for getSize in 2010 and this article was helpful, I thought I’d answer the question for anyone else who has to use getSize in 2010.

    Large and normal do not work in 2010, only 0 and 1.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>