5

I'm trying to create a custom ribbon in one of my Excel 2010 addins, and for some reason Office is overriding some of the keytips (keyboard accelerators). I know if Office sees a conflict it will usually override one or both of the keytips to "Y", "Y2", "Y3", etc.. but in this example I only have one button in my tab so there is no other control for it to conflict with.

Here is the XML:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
 <ribbon>
  <tabs>
   <tab id="tabid_1" label="SampleTab" keytip = "B">
    <group id="grpid_1" label="SampleGroup">
     <button id="btnid_1" label="SampleButton" keytip="Z" />
    </group>
   </tab>
  </tabs>
 </ribbon>
</customUI>

Instead of the SampleButton having a keytip of Z, it gets replaced with "Y2". I see this behavior regardless of the keytip of the Tab (which is currently "B"). I checked to make sure that there wasn't some other button with a keytip of "BZ" that might be conflicting, but didn't see any.

I also see that behavior if I try to make the keytip of the SampleButton be "Y", but I assume this is because all "Y*" keytips are reserved for conflicts.

Incidentally, I was also having this problem with a keytip of "C", but for some un-explained reason that was happening only when I didn't have a label for the <group>. As soon as I added a label to the <group>, "C" stopped being overridden with "Y2". Very strange behavior.

Anyone have any ideas what could be causing this? Thanks in advance!

Kara
  • 6,115
  • 16
  • 50
  • 57
aFlocker
  • 53
  • 1
  • 5

3 Answers3

4

I was having the same issue and I ended up just changing the keytip value from an uppercase "Z" to a lowercase "z" and it worked. No idea why. Hopefully it works for you.

Tony Karel
  • 176
  • 1
  • 10
  • 1
    So strange - I thought I had tried that but I guess not... I'll take it though - Thanks! – aFlocker Jun 07 '13 at 16:51
  • Sadly, this also displays the keytips as lowercase letters after you press the Alt key. However, it's the only solution I've found so far. +1 – oddacorn Nov 03 '16 at 15:53
  • Another option, and one that I ended up going with, is to use a different letter or number for the KeyTip. Of course you have to verify that it's available, and some keystrokes that aren't displayed in the ribbon are reserved for use to maintain compatibility with shortcuts from older versions of Office. It is really weird that lowercase letters work in some cases since there's no functional difference in terms of what key you press. – oddacorn Nov 03 '16 at 17:45
0

This is the standard behaviour for custom (as opposed to builtin) tabs in an office application. To test this yourself simply add a couple of custom tabs through the UI. next hit the ALT key and notice how all of the custom tabs are Y1, Y2, Y3, accelerators..

However as noted by the OP, this shouldn't be the behaviour when setting the keytip property programmatically or through XML for the addin's ribbon UI elements. Since it only happens with a limited subset of key combos I'd imagine it could be a bug. Recommend logging this on the microsoft connect website.

Anonymous Type
  • 3,051
  • 2
  • 27
  • 45
  • why doesn't it belong on SO? I'm programming an Excel addin and this is one of the problems I've come across. – aFlocker May 07 '13 at 17:59
  • Anyways, when you have a custom Tab and actually set the KeyTip (something you can't do through the UI), either through code by setting the RibbonTab.KeyTip Property, or by editing customUI XML file, as long as there isn't a conflict, it will work just fine. If I make the keytip on the tab "B" and the keytip on the button "R", or any other letter, it will work just fine. Only when I make the button keytip "C" or "Z", does it think there is some conflict and replace the "C" and "Z" with "Y2", etc... – aFlocker May 07 '13 at 18:08
  • The problem is, there is no conflict (i.e. there are no other buttons with that same set of key shortcuts) but it's still replacing my keytip with the Y# ones. – aFlocker May 07 '13 at 18:08
  • ok thanks for clarifying i will edit my answer, as your right this is SO. – Anonymous Type May 09 '13 at 02:28
0

Sorry but the accepted answer didn't work for me! In my VSTO solution I empirically found a working ALT-Shortcut is "G". So in my C# code I set:

Globals.Ribbons.GetRibbon<MyRibbon>().tabMyRibbonTab.KeyTip = "GGG";

I use three G's to minimize conflicts with other Add-Ins. This worked for me and I could even select the RibbonTab in Excel 2007 by using SendKeys (see this other question).

Regards, Jörg

Community
  • 1
  • 1
jreichert
  • 1,466
  • 17
  • 31