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 / Excel / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Adding Controls in a toolbar?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
joe - 20 Feb 2006 20:48 GMT
How can I add controls to a toolbar, using VBA code?
Kevin B - 20 Feb 2006 21:05 GMT
This will add a new control to the worksheet menu bar:

Sub NewControl()

   Dim cmd As CommandBarButton
   
   Set cmd = Application.CommandBars("Worksheet Menu Bar"). _
       Controls.Add
   
   With cmd
       .BeginGroup = True
       .Caption = "My New &Button"
       .Style = msoButtonCaption
       .BeginGroup = True
       .OnAction = "Insert Macro Name Here"
   End With
   
OnExit:

   Set cmd = Nothing
   
End Sub

Signature

Kevin Backmann

> How can I add controls to a toolbar, using VBA code?
Kevin B - 20 Feb 2006 21:09 GMT
I was a bit too fast with the mouse click.

The .Caption statement is the name of your command with the ampersand
indicating which letter is the hot-key.  And the OnAction statement is the
name of the macro you want to execute when the user clicks the button.
Signature

Kevin Backmann

> How can I add controls to a toolbar, using VBA code?
 
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.