如何获得dropDown控件的值?
function区上的dropDown:
<dropDown id="dd01" onAction="dd01OnAction"/>
在VBA我需要
Sub dd01OnAction(control As IRibbonControl, ID As String, index As Integer) If dd01.Value = "Sky" Then MsgBox "323" End Sub
我怎样才能得到dropDown的价值?
我不认为你可以直接得到价值。
我通常从集合对象中加载dropDowns,并确保集合中的ID与dropDown中的索引匹配。 这样我就可以根据callback中的索引或ID参数从集合中获取所有相关的值。 你可以使用类似的工作吗?
这是否意味着在Collection中每次更改之后,我需要使Ribbon失效? 妈妈咪呀,这将是几乎每次点击后
是的,但是,通过使用ribbonobject.InvalidateControl("ID")
您可以使特定的dropDown控件无效,而不是整个function区。
很简单的例子:
Sub dd01OnAction(control As IRibbonControl, ID As String, index As Integer) '***** Assumes that MyCollection is initialized elsewhere '***** and filled with strings :) Debug.Print "The value is " & MyCollection.Item(index) If MyCollection.Item(index) = "Sky" Then MsgBox "323" End Sub