Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank - 24 Feb 2005 15:55 GMT
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
Michael Schmidt - 26 Feb 2005 00:47 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.