我有一个带有几个切换按钮的自定义功能区。我希望在打开工作簿时按下按钮。有没有办法引用切换按钮,并将值设置为True?
答案 0 :(得分:0)
以下是您可以这样做的方法:
getPressed
; getPressed
回调关联的名称对应的子名称; returnedVal = True
。 注意:首次呈现功能区时以及无效时调用getPressed。在上述过程中,您应该正确维护分配给returnedVal
的值;而不是系统地返回True
,最初返回True
,但之后返回切换按钮的实际按下状态。
示例强>:
Option Explicit
Private m_bIsToggleButton1Pressed As Boolean
Public Sub Togglebutton1_getPressed(control As IRibbonControl, ByRef returnedVal)
returnedVal = m_bIsToggleButton1Pressed
End Sub
Public Sub Togglebutton1_onAction(control As IRibbonControl, ByRef cancelDefault)
m_bIsToggleButton1Pressed = Not m_bIsToggleButton1Pressed
End Sub
'This procedure is associated to the onLoad callback of the customUI root
'node in the Ribbon Designer.
Public Sub Test_onLoad(ribbon As IRibbonUI)
m_bIsToggleButton1Pressed = True
End Sub