How to use VBA to add a macro to a Word toolbar?

F

Frank

I want to use VBA to add a macro to a Word toolbar.

When I do this manually and record it in a macro, the resulting command is
simply:

CommandBars("Menu Bar").Controls.Add Type:=msoControlButton, Before:= 20

without any reference to the name of the given macro.

How do I write the VBA code to add a macro (say Normal.Modul1.Mymacro) to
the Standard toolbar in Word?

Thanks, Frank
 
M

Michael Schmidt

Try this:

dim objControl as Control
Set objControl = _
CommandBars("Menu Bar").Controls.Add(Type:=msoControlButton, Before:= 20)
objControl.OnAction = Normal.Modul1.Mymacro
Set objControl = Nothing

Michael.
 

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