To implement a custom Ribbon element we have to describe it using an XML file defined by the Microsoft CustomUI schema and load it using the Application.LoadCustomUI() procedure.
The root element of the XML file is customUI
. Inside of it there is the element ribbon
containing all the tabs, buttons etc.
A code snippet for loading of the xml file:
Dim f As Long
Dim strText As String
Dim strOut As String
f = FreeFile
Open "\customUI.xml" For Input As f
Do While Not EOF(f)
Line Input #f, strText
strOut = strOut & strText
Loop
Application.LoadCustomUI "AppRibbon_1", strOut
Sample XML file:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="Tab1" label="Tab1">
<group id="Group" label="Group">
<button id="MyButton1" label="Button1" imageMso="_1"
onAction="doSomeAction"/>
<button id="MyButton2" label="Button2" imageMso="_2"
onAction="doSomeAction2"/>
</group>
<group id="Group2" label="Group2">
<button id="MyButton3" label="Button3" imageMso="_1"
onAction="doSomeAction3"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>