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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.