pass toolbar button clicked to sub/function

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

pass toolbar button clicked to sub/function

Post by Robie »

Hi

Just wondering if it is possible to pass a value or know which toolbar button was clicked of say 6. All doing exactly same except one minor change. Basically, calling the same sub to do multiple things.

Thanks.

Robie.

User avatar
Guessed
2StarLounger
Posts: 102
Joined: 04 Feb 2010, 22:44
Location: Melbourne Australia

Re: pass toolbar button clicked to sub/function

Post by Guessed »

What version of Word are you using?

I don't know how to do this in Word 2003 and looking at this VBA example it doesn't look like that author knows either (but he can create code that almost does it) -http://www.codeforexcelandoutlook.com/b ... look-2003/

In Word 2007 and 2010 it is very easy, you can either use the tag or id attributes of the control. eg
Sub ApplyStyle(control As IRibbonControl)
Selection.Style = control.ID
End Sub
Andrew Lockton
Melbourne Australia

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: pass toolbar button clicked to sub/function

Post by Robie »

Guessed wrote:What version of Word are you using?

I don't know how to do this in Word 2003 and looking at this VBA example it doesn't look like that author knows either (but he can create code that almost does it) -http://www.codeforexcelandoutlook.com/b ... look-2003/

In Word 2007 and 2010 it is very easy, you can either use the tag or id attributes of the control. eg
Sub ApplyStyle(control As IRibbonControl)
Selection.Style = control.ID
End Sub
Thank you. I will look into it.