用XML自定义Excel功能区
一、XML编写
<?xml version="1.0" encoding="utf-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="MyTab" label="测试标签">
<group id="Group1" label="测试组1">
<button id="Button1" label="测试按钮" imageMSO="T" size="large" onAction="test"/>
</group>
<group id="Group2" label="测试组2">
<menu id="J0101" label="显示菜单" imageMso="AccountMenu" >
<button id="customButton0201" label="显示主菜单" onAction="main" imageMso="ShapeRightArrow" />
<button id="customButton0202" label="显示明细菜单" onAction="submain" imageMso="SmartArtInsert" />
</menu>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
二、回调函数
Public Sub test(control As IRibbonControl)
MsgBox "Hello world!"
End Sub
Public Sub main(control As IRibbonControl)
MsgBox "show main!"
End Sub
Public Sub submain(control As IRibbonControl)
MsgBox "show submain!"
End Sub