Developing a ribbon tab in Word 2010, using ampersand symbol in group label name

笑着哭i 提交于 2019-12-12 09:42:02

问题


I'm developing a ribbon tab for use in a template (MyTemplate.dotm) for Word 2010.

My problem: I want to have an ampersand symbol (&) in the label for a group. I have tried many things, and also alot of googling about this issue, but nothing works:

(named)   &
(decimal) &
(decimal) &
(hex)     &

This is what I have tried, the xml saved in MyTemplate.dotm-file (with Custom UI Editor for Microsoft Office):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
  <ribbon>
    <tabs>
      <tab id="tabMyTemplate" label="myTemplate">

        <group id="grpCopyAndPasteCopy1" label="Copy&amp;Paste 1">
        <!-- HTML Entity (named) &amp; -->
        </group>
        <group id="grpCopyAndPasteCopy2" label="Copy&#38;Paste 2">
        <!-- HTML Entity (decimal) &#38; -->
        </group>
        <group id="grpCopyAndPasteCopy3" label="Copy&#038;Paste 3">
        <!-- HTML Entity (decimal) &#038; -->
        </group>
        <group id="grpCopyAndPasteCopy4" label="Copy&#x26;Paste 4">
        <!-- HTML Entity (hex) &#x26; -->
        </group>

      </tab>
    </tabs>
  </ribbon>
</customUI>

Here is the result when open MyTemplate.dotm in Word 2010:

Does anyone know how I should solve this problem?


回答1:


This is a common problem when working with standard menu items. A single ampersand (&) is interpreted as the shortcut key (the one that gets underlined when you hold down the Alt key).

To show a literal '&' in the caption, double them: Copy&&Paste. I'm not sure if you'll need to escape them or not (if you do, use &amp;&amp;, but the doubled characters should give you the output you want.



来源:https://stackoverflow.com/questions/21333786/developing-a-ribbon-tab-in-word-2010-using-ampersand-symbol-in-group-label-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!