标签:custom xmlns before sof bsp http etl control 动态获取
本例,在Excel右键菜单中创建一个按钮,按钮的标题使用getLabel动态获取,图标使用getImage动态获取。
customUI XML代码:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="OL"> <contextMenus> <contextMenu idMso="ContextMenuCell"> <button id="Button1" getLabel="GL" getImage="GI" insertBeforeMso="Cut"/> </contextMenu> </contextMenus> </customUI>
工作簿中的VBA回调代码:
Public R As IRibbonUI Public Sub OL(ribbon As Office.IRibbonUI) Set R = ribbon End Sub Public Sub GL(control As Office.IRibbonControl, ByRef label) label = Time End Sub Public Sub GI(control As Office.IRibbonControl, ByRef image) Dim rnd As Integer rnd = Application.WorksheetFunction.RandBetween(65, 90) image = Chr(rnd) End Sub
效果演示:
源文件下载
想学习更多Office开发技能,赶紧加群联系群主!快满员了!
Office customUI中如何动态更新控件标题和图标?
标签:custom xmlns before sof bsp http etl control 动态获取
原文地址:https://www.cnblogs.com/ryueifu-VBA/p/9010991.html