自定义功能区 Excel XML

Custom ribbon Excel XML

我想使用 XML 在 MS Excel 中创建自定义项。在此项目中将有几个组,每个组中有许多按钮来回调 vba 宏。

我可以设置一组多个按钮XML(代码1),但我无法设置多个按钮组(代码2)。

我对 XML 不熟悉,所以我很感谢你指出我哪里出错了。

代码 1

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon startFromScratch="false">
        <tabs>
            <tab id="customTab" label="AA PAYMENTS APP" insertAfterMso="TabView">
                <group id="customGroup" label="Group 1">
                    <button id="customButton" label="Test1" imageMso="HyperlinkInsert" size="large" onAction="Callback" />
                    <button id="customButton2" label="JG Button 2" imageMso="PictureBrightnessGallery" size="large" onAction="Callback2" />
                    <button id="customButton3" label="Validate and Submit" imageMso="PictureBrightnessGallery" size="large" onAction="Callback3" />
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

代码 2

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon startFromScratch="false">
        <tabs>
            <tab id="customTab" label="AA PAYMENTS APP" insertAfterMso="TabView">
                <group id="customGroup" label="Group 1">
                    <button id="customButton" label="Test1" imageMso="HyperlinkInsert" size="large" onAction="Callback" />
                    <button id="customButton2" label="JG Button 2" imageMso="PictureBrightnessGallery" size="large" onAction="Callback2" />
                <group id="customGroup2" label="Group 2">
                    <button id="customButton3" label="Validate and Submit" imageMso="PictureBrightnessGallery" size="large" onAction="Callback3" />
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

N.B 我使用自定义 UI 编辑器。

您必须先关闭 </group> 的群组,然后才能开始 <group> 的新群组。我想你也许可以嵌套它们(我从未尝试过)但你没有正确关闭嵌套。每个 <group> 都需要用 </group>.

结束
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon startFromScratch="false">
        <tabs>
            <tab id="customTab" label="AA PAYMENTS APP" insertAfterMso="TabView">
                <group id="customGroup" label="Group 1">
                    <button id="customButton" label="Test1" imageMso="HyperlinkInsert" size="large" onAction="Callback" />
                    <button id="customButton2" label="JG Button 2" imageMso="PictureBrightnessGallery" size="large" onAction="Callback2" />
                </group>
                <group id="customGroup2" label="Group 2">
                    <button id="customButton3" label="Validate and Submit" imageMso="PictureBrightnessGallery" size="large" onAction="Callback3" />
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>