0

I have a label with a ribbon callback getLabel that I want to include ampersands in.

I know that, when defining ribbon XML, I need to escape and double it, so & becomes &&.

But, escaping doesn't work in a callback, which makes sense because it's expecting a non-escaped value. And doubling up just makes the second ampersand underlined. If I add a third ampersand, the first two correctly output without an underline, but the next character is underlined.

How do I do this from a callback without an underline?

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
Chris
  • 3,400
  • 1
  • 27
  • 41
  • According to this StackOverflow discussion the double ampersand should work: https://stackoverflow.com/questions/21333786/developing-a-ribbon-tab-in-word-2010-using-ampersand-symbol-in-group-label-name. I don't think there should be any difference between Office versions... – Cindy Meister Nov 28 '18 at 20:01
  • @CindyMeister That question is about defining it in ribbon XML directly, where mine is using a callback. I actually have it linked in my question already. – Chris Nov 28 '18 at 20:42

1 Answers1

0

One answer I have found, is that placing another ampersand at the end of the string makes it look the way I want it. I suppose the way it works, is that it insists on an underline wen handling callbacks, and it uses the last ampersand in the string to do it. If the last one is at the end, then there's nothing after that, and there's nothing to underline.

While this does work for my case, I am hesitant to use it because it seems like an unintended workaround. I am not sure that it will be reliable in future versions (I am targeting only 2013 right now, as that is what my customer uses).

Chris
  • 3,400
  • 1
  • 27
  • 41