更改自定义 Excel 功能区下拉菜单的大小

Change size of Custom Excel Ribbon dropdown

我在功能区中有这个下拉菜单,其中包含工作簿中所有可见的 sheet。用户可以在其中 select a sheet 跳转到它。这很重要,因为此工作簿中有大量 sheet。不幸的是,当 sheet 的名称很长时,它不会完全显示。 我想把它加宽。

我使用 CustomUI Editor for Microsoft Office 以我不太流利的 XML 技能来创建它。这是部分代码:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="InitS3Ribbon">
    <ribbon>
        <tabs>
            <tab id="s3Tab" label="S3 Menu">
                <group id="grGeneral" label="General">

                    <dropDown id="navigation" label="Navigation" getItemCount="GetNavigateItemCount" getItemLabel="GetNavigateLabel" onAction="MenuNavigate" getSelectedItemIndex="SetNavigateIndex" showLabel="true" />

                    <button id="bShowHideSheet" imageMso="PivotPlusMinusButtonsShowHide" label="Show/Hide sheets" size="normal" onAction="MenuShowHideSheets" />
                    <button id="bPreviousPage" imageMso="LeftArrow2" label="Previous sheet" size="large" onAction="MenuPreviousSheet" />
                    <button id="bNextPage" imageMso="RightArrow2" label="Next sheet" size="large" onAction="MenuNextSheet" />
                </group>

我找到了 this resource saying that it can be changed with the SizeString 属性,但我什至不确定如何或在哪里将其包含在我的代码中。在我看来它应该在 VBA 部分?我不确定我是否理解,我需要指导。我不确定现在是否编辑 XML 或 VBA 以及如何编辑。

可在此处找到官方 XML 规范:https://msdn.microsoft.com/en-us/library/cc313070(v=office.12).aspx

看起来 sizeString 可以直接用作下拉列表 XML 标记的属性。所以像:

<dropDown id="navigation" label="Navigation" sizeString="MY_MAX_LENGTH_STRING" getItemCount="GetNavigateItemCount" getItemLabel="GetNavigateLabel" onAction="MenuNavigate" getSelectedItemIndex="SetNavigateIndex" showLabel="true" />

您只需要知道您将遇到的最长字符串是多少,然后将其输入为 MY_MAX_LENGTH_STRING。考虑到您正在使用下拉列表来保存工作表名称(上限为 31 个字符),您可能会使用该长度作为起点。