我想使用XML在MS Excel中创建自定义项。在这个项目中,将有几个组,并在每个组内有一些回调vba宏的buttoms。
我能够设置多个按钮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编辑器。
答案 0 :(得分:1)
在使用</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>