Это то, что у меня есть, но я все еще новичок.
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnRibbonLoad">
<ribbon>
<tabs>
<tab id="MyTools" label="Tools">
<group id="MoveGroup" label="Move" tag="GroupMove" >
<button id="MoveColumnLeft" tag="EnableLeft" imageMso="GoRtl" screentip="Move Column Left" supertip="Move the selected column to the left" label="Left" size="large" onAction="OnActionButton" getEnabled="GetEnabled" />
<button id="MoveColumnRight" tag="EnableRight" imageMso="GoLeftToRight" screentip="Move Column Right" supertip="Move the selected column to the right" label="Right" size="large" onAction="OnActionButton" getEnabled="GetEnabled" />
`<separator id="MoveSep" />`
<button id="MoveRowUp" tag="EnableUp" imageMso="MessagePrevious" screentip="Move Row Up" supertip="Move the selected row up" label="Up" size="large" onAction="OnActionButton" getEnabled="GetEnabled" />
<button id="MoveRowDown" tag="EnableDown" imageMso="MessageNext" screentip="Move Row Down" supertip="Move the selected row down" label="Down" size="large" onAction="OnActionButton" getEnabled="GetEnabled" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Option Explicit
Public oRibbon As IRibbonUI, bEnabled As Boolean
Sub OnRibbonLoad(ribbon As IRibbonUI)
Set oRibbon = ribbon
bEnabled = True
End Sub
Sub OnActionButton(control As IRibbonControl)
Select Case control.ID
Case "MoveColumnLeft"
bEnabled = enabled
oRibbon.Invalidate
Case "MoveColumnRight"
bEnabled = enabled
oRibbon.Invalidate
End Select
End Sub
Sub GetEnabled(control As IRibbonControl, ByRef enabled)
`Select Case control.ID
Case "MoveColumnLeft"
enabled = enabled
Case "MoveColumnRight"
enabled = enabled
End Select
End Sub