Pass Ribbon Button ID to Macro

C

chris seiter

I have a custom tab in 2007 that contains a drop-down menu. Each item in the
menu is different, but the macro will perform the same function with a few
differences based on which menu option is selected. How can I pass the id of
the menu item pressed to the macro so I don't have to write 7 different
macros for each? I'd like to just use a Select Case for the name and change
the items based on that.
 
G

Greg Maxey

Chris,

The "ID" of the menu button pressed is available in the VBA callback:

Sub ButtonOnAction(control As IRibbonControl)
'Pass the ID as an argument to a separate macro
YourMacro control.ID
End Sub

Sub YourMacro(ByRef pStr as String)
Select Case pStr
Case "Btn1"
'Do this
Case "Btn2"
'Do that
Case "Btn3"
'Do something else
End Select
 

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