|
Printer-friendly version:
|
|
 |
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:
EmailCleanup
Run Macro
|
To clean up email that has been
copied/pasted into Word; removes > and | characters, manual line
breaks, multiple spaces, etc. |
FolderContents
Run Macro
|
Creates a new document that lists the
file names in a specified folder, defaulting to current folder but
displaying a dialog to let you choose the path. |
|
|
Figure 1
|
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.
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:
|
1.
|
Go to Tools/Templates and Add-Ins.
|
|
2.
|
Click the Add button and locate the 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.
|