Organizing your macros
Article contributed by Beth Melton
Many of us have a multitude of macros. I have too many to want them all cluttering up my menus, or to remember keyboard shortcuts for them all. Rather than having to look though your list of macros in the Macros dialog, or in the VB Editor, to find the one you want, the following methods may help to make it easier to find/edit/run the macro you want with a few clicks of the mouse; and if you have as many macros as me, will speed up Word as well.
Getting yourself organized
First categorize the macros into different Templates and Add-ins.
Macros that are intended for use with specific document types should be placed in the template you base those documents on.
I suggest creating at least two add-ins. One for those you frequently use and want to have loaded automatically when Word starts and one for those you don't use as often.
If you want to further categorize the macros within the add-ins, you can create various modules:
1. |
With your add-in open, go into the VB Editor (Alt+F11). |
2. |
In the Project pane, select the
“project”
(add-in). |
3. |
Select Insert/Module. |
4. |
Change the name of the Module in the Properties pane (if it isn't
visible, press F4). |
In each add-in, add each of the macro names and descriptions in the document itself, in a two column Word table.
For each macro you can also include a MacroButton field so you can double-click it to run the macro:
{ MACROBUTTON EmailCleanup Run Macro }
For example:
|
||||
Figure 1 |
Or create a custom toolbar or menu in the add-in, that invokes the macros, as in Figure 2. See How to assign a Word command or macro to a toolbar or menu. |
|
Editing Macros
If you want a very quick way to get to the macro you want in order to edit it, store the following macro in Normal.dot, or in an add-in that automatically loads; it opens the VBA editor and takes you directly to the macro whose name you have selected in the current document:
Sub EditMacro()
With Dialogs(wdDialogToolsMacro)
.Name = Selection.Text
.Edit = True
. Execute
End With
End Sub
Add a custom button on one of your Toolbars so you can just double-click a macro name to select it and run the EditMacro macro.
(If you do choose to utilize Normal.dot, keep a backup of it in the event it should become lost or corrupt. As an additional note, the same should be done with all of your valuable templates.)
Organizing your Global Templates
Global templates fall into three categories, Normal.dot; add-ins that automatically load when Word starts, and add-ins that you manually load as needed.
To automatically load an add-in when Word starts, place either it, or a shortcut to it, in Word's Startup folder. This location can be obtained from Tools/Options/File Locations.
For help on finding the Startup folder in Word 2007 and later versions, see How to find the Word Startup folder.
Add-ins you wish to manually load can be placed in any folder except Word's Startup folder. I place all my add-ins in the same folder as each other, and put a shortcut in Word's Startup folder to those Add-ins that I want Word to load automatically. Only loading addins when they are needed can speed up Word.
To manually load an add-in:
When Word restarts they will still be in the list, just unloaded. When you need them all you have to do is go back to Tools/Templates and Add-Ins, and tick the appropriate one. |
|
In my setup, I also include a couple of templates that come with Microsoft Word as global templates too. Since I have several, I have created a UserForm to make loading them easier:
I have named my option buttons, respectively (from top to bottom): optWordMcr, optMacros and optSupport.
Here are the necessary macros for this UserForm:
In your project module:
Sub ShowGlobalTemplates()
frmGlobal.Show
End Sub
In your UserForm module:
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
If optWordMcr =
True Then
AddIns("C:\GlobalTemplates\Macros.dot").Installed
=
True
ElseIf optMacros = True
Then
AddIns("C:\GlobalTemplates\MACROS9.DOT").
_
Installed = True
ElseIf optSupport =
True Then
AddIns("C:\GlobalTemplates\SUPPORT9.DOT").
_
Installed = True
End If
Unload Me
End Sub
Work Menu
To make it easier to open my add-ins for editing, I have created a shortcut to each of them on my Work menu.