Frage

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!

War es hilfreich?

Lösung

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.

Andere Tipps

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.

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top