在Excel 2007功能区上,我添加带有按钮的新组。我需要能够根据首次打开工作表时检查的条件(例如onload事件)将标签文本从“ ABC_Execute”更改为“其他”-如何在VBA中进行操作?
用于自定义功能区的示例代码:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab id="customTab" label="ABC" insertAfterMso="TabHome">
<group id="customGroup" label="ABC Tools">
<button id="customButton1" label="ABC_Execute" size="large" onAction="Begin" imageMso="Bold" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
谢谢。
您需要将getLabel回调添加到CustomUI:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="rx_rib_on_load">
<ribbon>
<tabs>
<tab id="customTab" label="ABC" insertAfterMso="TabHome">
<group id="customGroup" label="ABC Tools">
<button id="customButton1" getLabel="rx_getLabel" size="large" onAction="Begin" imageMso="Bold" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
然后在工作簿模块中:
Sub rx_getLabel(control As IRibbonControl, ByRef returnedVal)
returnedVal = ThisWorkbook.Sheets("Sheet1").Range("A1").Value
End Sub
例如。如果随后需要更改该值,则需要一个onLoad回调,以便可以在需要时使控件/功能区无效。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句