Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to place a dropdown menu on a toolbar for Word 2003 2

Status
Not open for further replies.

ChetN

Technical User
Feb 9, 2001
42
US
Is there a way to place a dropdown list of macros onto a toolbar?

I want to click on the menu name, have it display a list of macros (each is a "Insert Comment" routine) where I can select the one I want.

C.N.

 
This should do what you want...
The following lines of code add a Menu item named "My Macros", and gives you two macros to choose from.
I tested it with Word 2003 and it worked fine.
You can use it as a starting point.
***********************************************
Sub AddMenuItem()
Dim cbMainMenu As CommandBar
Dim intHelpMenu As Integer
Dim cbcCustomMenuItem As CommandBarControl

On Error Resume Next

Set cbMainMenu = Application.CommandBars("Menu Bar")

'Get the position of the "Help" menu item
intHelpMenu = cbMainMenu.Controls("Help").Index

'Add a new menu item
Set cbcCustomMenuItem = cbMainMenu.Controls.Add(Type:=msoControlPopup, Before:=intHelpMenu)
cbcCustomMenuItem.Caption = "&My Macros"

'Add your macros to the pull down menu
With cbcCustomMenuItem.Controls.Add(Type:=msoControlButton)
.Caption = "Macro 1"
.OnAction = "Macro1"
End With

With cbcCustomMenuItem.Controls.Add(Type:=msoControlButton)
.Caption = "Macro 2"
.OnAction = "Macro2"
End With

End Sub
**********************************

It helps to be able to delete the menu item too, as every
time you run the code above it will create a new menu item.
So to delete the menu item...

Sub DeleteMenuItem()

'Remove a menu item
Application.CommandBars("Menu Bar").Controls("My Macros").Delete

On Error GoTo 0

End Sub
********************************

This should get you started. I'm not a big time programmer, more of a hacker actually:)
Good luck.
 
Or:
Click Tools - Customize. Select the Commands tab. Under Categories, scroll down to New Menu and select it. On the right under commands, you'll see New Menu. Click on it. Now this is a drag and drop. Drag it to the menu bar. It'll say New Menu. RIGHT click on it and change the name to something like My Macros. Enter.
In the Customize box, click the Command tab, scroll down to Macros and select it. On the right, you'll see Custom Menu Item. Click on it and drag it to your new My Macro menu. A square grey box will appear. Move your mouse down to the box and you'll see a black bar. Let go. You should now have a menu item called Custom Menu Item. Make sure it's selected, RIGHT click and change it's name. RIGHT click again and select Assign Macro. Select the macro you want and click OK.
Repeat the above paragraph to add the other macros.
When you close the Customize box, the menus and button become activated again.
 
To NWBeaver and Fneily,

Thanks to you both for the quick and helpful responses. I am now on the way to creating a very comprehensive toolbar.

Chet N.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top