How to assign a Word command or macro to a toolbar or menu
Article contributed by Dave Rado
- Choose Customize on the Tools menu.
- On the Commands tab, where it says “Save In”, select the template in which you want to save the changes you are about to make; or accept the default, which is usually to save them in your Normal.dot template (which will make your customization global). If you are new to this, you will probably want to accept the default:
For the sake of older hands: the “Save in” box defaults to “Normal.dot”, unless the current document is another template or add-in, in which case it defaults to that template or addin. If the current document is attached to a template other than Normal.dot, then you will be able to select that template by pulling down the “Save in” List, thus allowing you to make your customisation specific to documents based on that template, if that's what you want.
If you want to make the changes in an add-in, you need to open the add-in as the current document before you start.
If you want to create a new Toolbar, click on the “Toolbars” tab, click New, give the new toolbar a name, and choose which template you want to store the toolbar in:
Or, if you want to create a new menu, click on the “Commands” tab. In the Categories list, click New Menu. In the Commands list, drag the “New Menu” item onto the Menu Bar (or onto a toolbar – any toolbar can act as a menu bar):
- Then right-click on your new menu, and rename it.
- Put an ampersand (&) just before the character which you want to be the shortcut key (the underlined character) – for instance if your menu is called “/font>My macros”, and you want the user to be able to invoke it using Alt+M, you should name it “My ¯os” or “&My macros”.
Or, if you want to assign the command or macro to a shortcut menu (otherwise known as a “right-click” menu), click on the “Toolbars” tab, and select “Shortcut menus” in the list of toolbars. The “Shortcut menus” toolbar will be displayed, and you can modify the menus on that in the same way as any other menu:
- Once you've done that, select the Commands tab
- In the Categories list, choose All Commands to assign a Word command, or choose Macros to assign a macro. Then in the list on the right, choose a command or macro and drag it onto the menu or toolbar you want it to be part of.
- If you are customising a menu (including a shortcut/right-click menu), you will need to hold the mouse still until the menu drops down. Then position it, and only release the mouse when you have the command where you want it:
Note: If customising shortcut (i.e. context-sensitive right-click) menus, you may be surprised by how many menus you actually have to customise! For instance, if you want to add a command to the context-sensitive “Table” menus, you may well need to amend all of the menus shown in Figure 6. The trick here is, customise just one menu to start with. Then, when you're sure you've got it right, you can drag your new button, with your Ctrl key held down, to copy it from one menu to another. That way, you won't need to rename your buttons, or assign Tooltips or button images to them, more than once.
For a more detailed illustration of how to modify a shortcut
menu, see also:
How to fix the Word 2000+ Cell Alignment buttons
- Right-click on your new menu or toolbar button, and rename it (see Figure 3).
If you've dragged the command or macro onto a toolbar and only want an icon to appear, right-click on it, and change it from “Text only” to “Default Style”.
Then you can select “Edit button Image”, or “Change button image”; or “Paste button image”. In order to paste a button image, obviously you have to copy one first: You can copy an image from the document, or from another button; or from a graphic in a graphics package. For much more detail on this, see the article: Assigning custom button images to your toolbar and menu buttons.
If you've dragged the macro onto a menu, put an ampersand (&) just before the character which you want to be the shortcut key (the underlined character) – for instance if your button is called “Heading Numbering”, and you want the user to be able to invoke it by pressing N, you should name it “Heading &Numbering”. And again, see also: Assigning custom button images to your toolbar and menu buttons.
- Click Close.
Hold your Shift key down and select File + Save All, in order to save the changes in your template or add-in.
If it is a macro that you're assigning, and if you capitalise your macro name so that the first letter of each “word” is capitalised and the rest is lower case, then the Tooltip will automatically have spaces between the “words”; so that a macro called “HeadingNumbering” would automatically have a Tooltip of “Heading Numbering”.
Whether it's a macro or a command that you're assigning, if you want to change the Tooltip text which appears when a user hovers over the button, you have to run a line of code such as the following – but this is a one-off – you only need to run the code once (you could run it from the Immediate Window – press Ctrl+G, or select View + Immediate Window):
TooltipText = "My tooltip text"
Or if your button is on a menu you'd use something like:
.Controls("NameOfMyNewButton").TooltipText = "My tooltip text"
- Then select b> File + Save All again.
If it is a macro that you're assigning to a menu button, and if you want the menu to display the keybaord shortcut that's been assigned to your macro (in the same way that the File + Save menu button displays Ctrl+S, over on the right), see: How to get a menu button that is assigned to a macro to display the keyboard shortcut on the menu.
For a more detailed illustration of how to modify a shortcut menu, see:
How to add a command or macro to a menu (Word 2003 and earlier)
How to add a command or macro to the Quick Access Toolbar (Word 2007 and above)
“How to add a command or macro to a toolbar (Word 2003 and earlier)