开发者

Change button label in Ribbon using VBA

I have a custom 开发者_开发百科Tab I have created. How can I use VBA to change the attributes of the controls on the tab. For example, I would like to change the label of a button with id="menubutton" depending on user seelctions in the program. It seems to me that it should be easy but I am struggling with this. Any help would be greatly appreciated.


You can try getLabel function with XML you can change your button label like this

<button id="customButton" getLabel="getLabel1" size="large"  onAction="Example_Macro"  />

With VBA you can use this macro to change label

Sub getLabel1(control As IRibbonControl, ByRef returnedVal)
 returnedVal = "Hello"
End Sub

returnedVal will be your label for button.


Can you do this yourself (eg with the mouse and keyboard) in Word via the customise toolbars context menus?

  1. If so then switch on the macro recorder.
  2. Perform the action (eg use the keyboard and mouse to change the attributes you wish to ).
  3. Stop the macro recorder.
  4. Open up the VBA studio in Word and take a look at the macro that has been created, that should give you a good indication of what you need to do.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜