Word: Separate out macros and attach them to all documentsOctober 18, 2009
(Many thanks to Hamish Blunck for helping me with this tip)
I needed to make some macros available to all Word documents I opened. I wouldn’t need the macros for every document, but I would need them for many documents. The documents I was working on used different templates, so adding the macro to each template was not an option. In addition, some of the documents came from organizations where I had no access to, nor control over, their templates. Adding the macro to my Normal.dot template wasn’t an option either — if Normal.dot gets corrupted or deleted, Word will create a new one based on the ‘factory defaults’ — and I would lose all my macros.
What I wanted was a place where I could store all my handy Word macros, and I wanted the macros to be available to all my Word documents, whether I used any of them in a particular document or not.
The ‘quick and dirty’ solution for those who know about these things is to:
- Create and save a new blank document as a template (Word 2003: *.dot; Word 2007: *.dotm).
- Add your favorite macros and any keyboard assignments to this template. Save and close.
- Move your macros template to the Word > STARTUP folder.
For those who require more steps…
Create a new template document for your macros
- Create a new document in Word.
- Immediately save it with a meaningful name (like macros) as a Document Template file type (Word 2003: macros.dot; Word 2007: macros.dotm).
Don’t close your new template yet — you’re going to add your macros to it next.
Add your macros to your macros template
Macros can come from various places — existing Word documents or templates, the internet, or you can create or record them from scratch.
The critical thing is to locate them then add them to your new macros.dot(m) document.
- Open the Macros dialog box (Word 2003: Tools > Macro > Macros; Word 2007: Developer tab > Code group > Macros button).
- Type anything in the Macro name field (you’ll be deleting it in a moment, so don’t worry about what it is).
- Click Create.
- Delete the macro information just created, then paste your favorite macros into the Code window. Each macro should start with a Sub line and end with an End Sub line.
- Close the Code window and the Microsoft Visual Basic window to return to your blank document.
Add any keyboard assignments to your macros template (optional)
If you like to run your macros using the keyboard, then now is the time to assign your keyboard combinations to your macros.
- Go to Tools > Customize (Word 2003) OR Office button > Word Options > Customize (Word 2007).
- Click Keyboard (Word 2003) OR Customize (Word 2007; Hint: This button is near the bottom of the window).
- On the Customize Keyboard dialog box, select Macros from the Categories list.
- Select one of your macros from the list of macros on the right.
- Click in the Press new shortcut key field.
- Press the keys you want to assign to this function.
- Select the template where you want to save this keyboard combination (select your new macros.dot(m) template).
- Click Assign.
- Click Close to close the Customize Keyboard dialog box.
- Close the Customize dialog box (Word 2003) OR the Word Options dialog (Word 2007).
- Save and close your macros.dot(m) document.
Move your macros template to your Word STARTUP folder
- Copy your macros.dot(m) template document to the clipboard.
- Paste it into your Word STARTUP folder; by default, it is located here:
- Word 2003: C:\Users\<UserName>\Application Data\Microsoft\Word\STARTUP
- Word 2007: C:\Users\<UserName>\AppData
- You can check your Startup folder location here:
- Word 2003: Tools > Options > File Locations tab. Select Startup, then click Modify to see the full file path.
- Word 2007: Office button > Word Options > Advanced > General section (near the bottom). Click File Locations, then select Startup. Click Modify to see the full file path.
Now whenever you open a Word document or create a new one, the macros in your macros.dot(m) file will be available for you to use.
Very clever. Thanks Hamish!
[Links last checked January 2013]