Which sub does a toolbar call?

B

Bob

I took over the support of Word macros done by other people and they were
heavy on the toolbars. The problem I'm having is I have all these toolbars I
need to debug and I can't figure out which sub they call. I actually tried
using this code

MsgBox Me.CommandBars("test1").Controls("test2").OnAction

but it returns an empty string. I can set it like and return what I set but
that doesn't help me.
 
Z

zkid

Hi Bob,

Plug in the toolbar name and give this macro a try. The buttons are in
order from left to right. So, for each button, change the Item number in
sequence (i.e., 1 becomes 2, 2 becomes 3, etc.)

Sub GetToolbarMacro()

Dim myBar As CommandBar

Set myBar = CommandBars("[toolbar name]")
MsgBox myBar.Controls.Item(1).OnAction

End Sub
 
W

Wraithchilde

Excellent. Item was the member I was missing. Thanks.

zkid said:
Hi Bob,

Plug in the toolbar name and give this macro a try. The buttons are in
order from left to right. So, for each button, change the Item number in
sequence (i.e., 1 becomes 2, 2 becomes 3, etc.)

Sub GetToolbarMacro()

Dim myBar As CommandBar

Set myBar = CommandBars("[toolbar name]")
MsgBox myBar.Controls.Item(1).OnAction

End Sub


Bob said:
I took over the support of Word macros done by other people and they were
heavy on the toolbars. The problem I'm having is I have all these toolbars I
need to debug and I can't figure out which sub they call. I actually tried
using this code

MsgBox Me.CommandBars("test1").Controls("test2").OnAction

but it returns an empty string. I can set it like and return what I set but
that doesn't help me.
 
Z

zkid

Glad I could help. This is just the best community, isn't it?! Especially
Helmut, Jay, Jean-Guy and Charles - you guys are so helpful and patient.

Wraithchilde said:
Excellent. Item was the member I was missing. Thanks.

zkid said:
Hi Bob,

Plug in the toolbar name and give this macro a try. The buttons are in
order from left to right. So, for each button, change the Item number in
sequence (i.e., 1 becomes 2, 2 becomes 3, etc.)

Sub GetToolbarMacro()

Dim myBar As CommandBar

Set myBar = CommandBars("[toolbar name]")
MsgBox myBar.Controls.Item(1).OnAction

End Sub


Bob said:
I took over the support of Word macros done by other people and they were
heavy on the toolbars. The problem I'm having is I have all these toolbars I
need to debug and I can't figure out which sub they call. I actually tried
using this code

MsgBox Me.CommandBars("test1").Controls("test2").OnAction

but it returns an empty string. I can set it like and return what I set but
that doesn't help me.
 

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