码迷,mamicode.com
首页 > 其他好文 > 详细

Office customUI中如何动态更新控件标题和图标?

时间:2018-05-08 22:18:42      阅读:156      评论:0      收藏:0      [点我收藏+]

标签: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

 

效果演示:

技术分享图片

 

源文件下载 

右键菜单显示时间.rar

想学习更多Office开发技能,赶紧加群联系群主!快满员了!

 

Office customUI中如何动态更新控件标题和图标?

标签:custom   xmlns   before   sof   bsp   http   etl   control   动态获取   

原文地址:https://www.cnblogs.com/ryueifu-VBA/p/9010991.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!