I am attempting to read the value of a custom combobox on the ribbon, which I have added to the ribbon using "customUI", using a VBA subroutine that is called when I click a custom button on the ribbon.
Here is my XML code:
'Here is my VBA Code:
Originally I was attempting to ready the value of the combobox directly with a macro and I was not having any luck. After some marginally successful google searching I discovered that the "onAction" procedure would likely be required in which the value of the combobox would be passed to a private variable declared in the VBA and can then be read by other subroutines. However, I have attempted to add the "onAction" command the combobox and my xml editor gives me the error "The 'onAction' attribute is not declared" when I attempt to validate my XML code. The example that mentioned the "onAction" procedure was also using a DropDown instead of a combobox.
It does not matter to me if I have to use a dropdown or a combobox nor does it matter if I read the values directly or indirectly though the "onAction" procedure. Any assistance would be greatly appreciated.
Thanks,
Curtis</BUTTON>
Here is my XML code:
Code:
<customUI xmlns="<a href=" target="_blank" customui? 01 2006 office schemas.microsoft.com http:>http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab id=test insertAfterMso="TabHome" label="Test Tab">
<group id=customGroup1 label="Test Group">
<BUTTON id=customButton1 type=submit label="Display" imageMso="HappyFace" onAction="ShowAP" size="large">
<comboBox id=conv
</comboBox> getItemCount="conv_getItemCount"
getItemLabel="conv_getItemLabel"
onAction="APDropdown" />
<comboBox id=sunit
</comboBox> getItemCount="rxgal_getItemCount"
getItemLabel="rxgal_getItemLabel"
getItemScreentip="rxgal_getItemScreentip" />
<comboBox id=dunit
</comboBox> getItemCount="rxgal_getItemCount"
getItemLabel="rxgal_getItemLabel"
getItemScreentip="rxgal_getItemScreentip" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
'Here is my VBA Code:
Code:
Option Explicit
Private m_blnChecks(1 To 3) As Boolean
Private m_strDropID As String
Sub rxgal_getItemCount(control As IRibbonControl, ByRef returnedVal)
'This callback tells the RibbonX how many labels you use in the gallery.
returnedVal = 9
End Sub
Sub rxgal_getItemLabel(control As IRibbonControl, index As Integer, ByRef returnedVal)
'This callback runs for every item (label).
'Use this if you want to use the cell values of "A1:A12" on Sheet2 as Label names.
' returnedVal = Sheets("Sheet2").Cells(index + 1, 1).Value
'This example uses the values in the array for Label names.
Dim Labelname As Variant
Labelname = _
Array("one", _
"two", _
"three", _
"four", _
"five", _
"six", _
"seven", _
"eight", _
"nine")
On Error Resume Next
returnedVal = Labelname(index)
On Error GoTo 0
End Sub
Sub conv_getItemCount(control As IRibbonControl, ByRef returnedVal)
'This callback tells the RibbonX how many labels you use in the gallery.
returnedVal = 1
End Sub
Sub conv_getItemLabel(control As IRibbonControl, index As Integer, ByRef returnedVal)
'This callback runs for every item (label).
'This example uses the values in the array for Label names.
Dim Labelname As Variant
Labelname = _
Array("Tester")
On Error Resume Next
returnedVal = Labelname(index)
On Error GoTo 0
End Sub
Sub rxgal_getItemScreentip(control As IRibbonControl, index As Integer, ByRef returnedVal)
'This callback runs for every item(label).
'This example will use the values in the array for screen tips.
Dim Tipname As Variant
Tipname = _
Array("Tip 1", _
"Tip 2", _
"Tip 3", _
"Tip 4", _
"Tip 5", _
"Tip 6", _
"Tip 7", _
"Tip 8", _
"Tip 9", _
"Tip 10", _
"Tip 11", _
"Tip 12")
On Error Resume Next
returnedVal = Tipname(index)
On Error GoTo 0
End Sub
'Callback for APIDropDown onAction
Sub APDropdown(control As IRibbonControl, id As String, index As Integer)
m_strDropID = id
End Sub
'Callback for AP05 onAction
Sub ShowAP(control As IRibbonControl)
Dim strTemp As String
strTemp = "DropDown " & vbTab & m_strDropID & vbLf
MsgBox strTemp, vbInformation
End Sub
Originally I was attempting to ready the value of the combobox directly with a macro and I was not having any luck. After some marginally successful google searching I discovered that the "onAction" procedure would likely be required in which the value of the combobox would be passed to a private variable declared in the VBA and can then be read by other subroutines. However, I have attempted to add the "onAction" command the combobox and my xml editor gives me the error "The 'onAction' attribute is not declared" when I attempt to validate my XML code. The example that mentioned the "onAction" procedure was also using a DropDown instead of a combobox.
It does not matter to me if I have to use a dropdown or a combobox nor does it matter if I read the values directly or indirectly though the "onAction" procedure. Any assistance would be greatly appreciated.
Thanks,
Curtis</BUTTON>