Parameter passing to MSWord macros

J

Jay

Is it possible to pass a parameter to a macro in a right-click pop-up
menu button click?
commandbarbutton.onAction..

For instance..

Dim ct3_PopUp as CommandBarButton
Dim parameter as string, tmp as string, tmp1 as string

With ct3_PopUp
.caption = ...
tmp = "(" & parameter & ")"
tmp1 = "macro1" & tmp
.OnAction = tmp1
End With

Public Sub macro1(desc as string)
MsgBox desc
End Sub
 
H

Helmut Weber

Hi Jay,
in a right-click pop-up menu button click?

I may be on an entirely wrong track,
but if I right-click in the menu bar,
I get a list of the available icon bars.

If you like, you can add a sub-menu or an additional icon bar.
But I'd rather make it accessible directly
by adding such a menu or an icon bar to the existing
menu bar or to an existing icon bar,
containing smallest possible macros
like "Macro001", "Macro002", "Macro003", connected to
a bigger macro and pass whatever parameters you like to it.
Be it defined in the smaller macros or be it defined
by a range, the selection, or whatever data are availabe.

Commandbarbutton.onAction seems to be only useful,
if you add Commandbarbuttons dynamically.

I wonder...

Sub Test001()
BigMacro "001"
End Sub
Sub Test002()
OnAction
BigMacro "002"
End Sub
Sub Test003()
BigMacro "003"
End Sub
Sub BigMacro(aStr As String)
MsgBox aStr
Application.CommandBars("NewMenu").Visible = False
End Sub

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 

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