Excel Excel ribbon XML callback with parameter

Joined
Oct 27, 2009
Messages
3
Reaction score
0
Dear Excel Gurus,

I have created some buttons A,B,C, D,E,...etc on the ribbon using XML.
Also I have the VBA sub:
sub test(s as String,i as integer)
MsgBox s & i
end sub

I want the following to happen:

1. test("string1",10)
to be executed when the button A is pressed
2. test("string2",10)
to be executed when the button B is pressed
and so on ...

How to define the onaction attribute for each button A,B,C,...etc
I want to know if callback with parameter can be used at all
or i have to create each callback seperately.

Thanks to All
 
Joined
Oct 27, 2009
Messages
3
Reaction score
0
Hey Guys,

I figured this out.

XML:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab id="customTab" label="Custom Tab">
<group id="customGroup" label="Custom Group">
<button id="customButtonA"
label="Custom Button A"
imageMso="HappyFace"
size="large"
onAction="customButtonA_onAction" />
<button id="customButtonB"
label="Custom Button B"
imageMso="HappyFace"
size="large"
onAction="customButtonB_onAction" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>

In VBA Standard Module:

'Callback for customButtonA onAction
Sub customButtonA_onAction(control as IRibbonControl)
call test("string1",10)
End Sub

'Callback for customButtonB onAction
Sub customButtonB_onAction(control as IRibbonControl)
call test("string2",20)
End Sub

Note:
I still want to know if callback with parameter can be used at all.
Here i have created each callback seperately.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top