Shifting Styles, Part 3

You're working away, editing a client's document, and decide to modify the Heading 1 style to use a Goudy typeface. Whoa! Now the Heading 2 and Heading 3 styles are in Goudy as well. What's going on here?

What's going on is that your client has made the Heading 2 and Heading 3 styles "based on" the Heading 1 style. If you don't know how this works, you'll be scratching your head over the changing formats. If you *do* know how it works, you can use it to ensure consistent formatting throughout a document.

Let's say you want all of your headings to be set in Baskerville. It's true that you could go through and set Heading 1, Heading 2, Heading 3, Heading 4, Heading 5, Heading 6, Heading 7, Heading 8, and Heading 9 (whew!) all to use that font (in varying point sizes, say). But now what if you want to switch to Palatino? Do you really have to go through and modify all of those styles again? Not if you originally based them all on Heading 1. If you did that, all you have to do is change the font for Heading 1, and all of your other heading styles will change as well. Pretty neat! Here's how to do it:

  1. Click the "Format" menu.
  2. Click "Style."
  3. In the Styles list, click the style (Heading 2, for example) that you want to base on another style (such as Heading 1).
  4. Click the "Modify" button.
  5. In the "Based on" dropdown list, click the style on which you want to base the current style.
  6. Click the "OK" button.
  7. Click the "Close" button.

Now, whenever you modify the "parent" style (Heading 1), the "child" style (Heading 2) will be modified automatically.

Please note, however, that any changes you make to the "child" style will override the attributes of the "parent" style. For example, if Heading 1 is set to 18 points, you can still modify Heading 2 (based on Heading 1) as 14 points. If you do that, though, you may wonder how to get rid of the override if you need to. Here's the secret: change the attribute in Heading 2 back to the way it's set in Heading 1 (14 points back to 18 points). The "child" style will simply pick up its attributes from the "parent style" once again.

This "based on" feature is extremely useful. You can use it to set up whole families of styles that are based on a "parent" style. For example, you might want to set up a family of heading styles, a family of body text styles, and a family of list styles, and then store them all in a special template. Just be sure to use a naming convention that makes it easy to remember which styles are the "parents." The easiest way to do this may be to use "1" to designate "parent" styles: Heading 1, Body Text 1, List 1, and so on. Then you can use other numbers (2, 3, 4) to indicate "child" styles.

Now, when your styles start shifting, you'll be happy rather than sad.

READERS WRITE

Last week's newsletter discussed Word's "Automatically update" feature for styles. In the newsletter, I suggested turning on the feature while designing a document but turning off the feature while writing or editing. If you've got lots of styles, however, this can get pretty tedious. Gary Frieder, a Microsoft Word MVP at Woody's Lounge (http://www.wopr.com) created a macro to turn off updating for all styles, and Bill Rubidge edited the macro to turn on updating. Thanks to Bill for sending the macros, and thanks to Gary for giving permission to use them. Enjoy!

'MACRO THAT CRAWLS ALL THE STYLES AND TURNS AUTO-UPDATE ON
Public Sub TurnOnAutomaticallyUpdate()
' TurnOnAutomaticallyUpdate Macro
' Created by Gary Frieder, edited by Bill Rubidge to turn on, not off
Dim aSty As Style
For Each aSty In ActiveDocument.Styles
   If aSty.Type = wdStyleTypeParagraph Then
   aSty.AutomaticallyUpdate = True
   End If
Next aSty
End Sub
 'MACRO THAT CRAWLS ALL THE STYLES AND TURNS AUTO-UPDATE OFF
Public Sub RemoveAutomaticallyUpdate()
' RemoveAutomaticallyUpdate Macro
' Created by Gary Frieder
Dim aSty As Style
For Each aSty In ActiveDocument.Styles
   If aSty.Type = wdStyleTypeParagraph Then
   aSty.AutomaticallyUpdate = False
   End If
Next aSty
End Sub

RESOURCES

Microsoft Product Support Services is actually one of my favorite places to find information about using Microsoft Word:

http://support.microsoft.com/

I just use the dropdown list on the left to select the version of Word I want to learn about (Word 2000, for example). Then I type some key words in the box just below that ("modify styles," for example), and click "Search now." The site has a lot of information, although you may have to dig to find just what you need.

Repeating Macros

If you record macros to help automate your editing, you've probably bumped into a seemingly insurmountable problem: You can get a macro to find something, and then do something, but not more than once. For example, let's say you want a macro to do this:

1. Find text formatted with the Heading 1 paragraph style.

2. Move to the next paragraph.

3. Insert these characters: "Tip. "

4. Repeat steps 1 through 3 until there aren't any more Heading 1 paragraphs to find.

You can get a macro to do steps 1 through 3, just by recording those steps. But how do you get it to do step 4 (other than running the macro 587 times)?

Well, you can't just record that part. You have to go *into* the macro and insert the commands that will make it repeat. Here's how to proceed:

IN WORD 97 AND ABOVE

1. Record the steps you want your macro to take (find something, then do something). You can learn more about recording macros here:

http://www.topica.com/lists/editorium/read/message.html?mid=1706651129

http://www.topica.com/lists/editorium/read/message.html?mid=1706748016

http://www.topica.com/lists/editorium/read/message.html?mid=1706832239

2. After you've stopped the macro recorder, click "Tools > Macro > Macros."

3. Click the macro you just recorded (you may need to scroll down the list to find it).

4. Click "Edit." The macro editor will open on your screen, showing the commands you've recorded. For example, if you recorded steps 1 through 3, above (way above: "1. Find text formatted with the Heading 1 paragraph style," and so on), here are the commands you'd see:

Selection.Find.ClearFormatting

Selection.Find.Style = ActiveDocument.Styles("Heading 1")

With Selection.Find

.Text = ""

.Replacement.Text = ""

.Forward = True

.Wrap = wdFindContinue

.Format = True

.MatchCase = False

.MatchWholeWord = False

.MatchWildcards = False

.MatchSoundsLike = False

.MatchAllWordForms = False

End With

Selection.Find.Execute

Selection.MoveDown Unit:=wdParagraph, Count:=1

Selection.TypeText Text:="Tip. "

(Note: If your version of Microsoft Word inserts the following command as the third line in the macro--"Selection.Find.ParagraphFormat.Borders.Shadow = False"--take it out. As far as I can tell, this comes from a bug in Microsoft Word, and you don't want it in there.)

You can probably tell by reading these commands what they do. All but the last three set up the parameters for your search. The third command from the bottom executes the search. All of this constitutes the "find something" part of the macro.

The last two commands constitute the "do something" part. In this example, they move down one paragraph and type in the string of characters. Our challenge, of course, is to get these commands to repeat--and then get the Find command to repeat. And to keep repeating everything until there's nothing left to find.

So here's the secret: Just before the "do something" part of the macro, insert the following command:

Do While Selection.Find.Found

That tells Word to keep doing the "do something" part as long as ("While") Word finds the "find something" part.

Of course, you also want Word to keep doing the "find something" part, too. So, you have to include the following command at the end of the "do something" part:

Selection.Find.Execute

That tells Word to execute the Find command again--as long as something continues to be found.

Finally, to tell Word where to *stop* repeating, you have to insert this command:

Loop

When you're finished, the whole thing will look like this (except that I've added an X to show you each command we've added):

Selection.Find.ClearFormatting

Selection.Find.Style = ActiveDocument.Styles("Heading 1")

With Selection.Find

.Text = ""

.Replacement.Text = ""

.Forward = True

.Wrap = wdFindContinue

.Format = True

.MatchCase = False

.MatchWholeWord = False

.MatchWildcards = False

.MatchSoundsLike = False

.MatchAllWordForms = False

End With

Selection.Find.Execute

X Do While Selection.Find.Found

Selection.MoveDown Unit:=wdParagraph, Count:=1

Selection.TypeText Text:="Tip. "

X Selection.Find.Execute

X Loop

That's it. Click "File > Close and Return to Microsoft Word."

Now, when you run the macro, it will *keep* running until it's finished all of the paragraphs you specified.

IN WORD 6 AND 95

Here's the macro as it appears in Word 6 and 95, with an X marking each line I've added to the recorded macro:

EditFindStyle .Style = "Heading 1"

EditFind .Find = "", .Direction = 0, .MatchCase = 0, .WholeWord = 0, .PatternMatch = 0, .SoundsLike = 0, .Format = 1, .Wrap = 1, .FindAllWordForms = 0

X While EditFindFound()

ParaDown 1

Insert "Tip. "

X EditFind

X Wend

_________________________________________

RESOURCES

Jean Hollis Weber has done it again, with her new book, Taming Microsoft Word 2000. Subtitled "Hot tips and cool tricks for business and technical documents," this 120-page compendium of basic but useful knowledge will help you become an instant expert on:

* Setting up Word 2000 to work your way

* Editing and reviewing documents

* Controlling page layout

* Using templates and styles effectively

* Getting the most from fields

* Working with large or complex documents

* Working with graphics

* Creating Web pages and PDF documents from Word

I'm especially impressed with the book's crystal-clear explanations, annotated screen shots, and elegant formatting. If you've been looking for a systematic treatment on mastering Microsoft Word, look no further. You can download a copy of the book here:

http://www.jeanweber.com/books/tameword.htm

Jean's previous book on taming Microsoft Word (for Word 6, 95, and 97) is also available:

http://www.jeanweber.com/books/tamewd97.htm

If you like either of these books, please be sure to compensate Jean for her efforts. You'll find payment instructions here:

http://www.jeanweber.com/bookshop/payme.htm

Creating Menus

Last week I explained how to create your own toolbars in Microsoft Word. You can create your own menus, too, as a place to activate macros or Word commands. Here's how:

In Word 97 or later:

1. Click the "Tools" menu.

2. Click "Customize."

3. Click the "Commands" tab.

4. In the "Categories" box (on the left), click "Menu" (you'll probably have to scroll down to find it).

5. In the "Commands" box (on the right), click "New Menu" and hold down your mouse button.

6. Drag your new menu (represented by a gray rectangle) up to Word's menu bar and drop it (by releasing the mouse button) where you want it to go. It will be displayed on the menu bar with the name "New Menu."

7. Back down in the "Customize" dialog, click the "Modify Selection" button. The customization menu will appear.

8. In the box labeled "Name," type the name for your menu, such as "Macros," and press your "Enter" key to make the change.

9. In the box labeled "Save in," select the template or document where you want your new menu to live. This will probably be your Normal template (Normal.dot), which will make the menu available to any document. You could also select another template or document, however.

10. Click the "Close" button.

In Word 6 or 95:

1. Click the "Tools" menu.

2. Click "Customize."

3. Click the "Menus" tab.

4. Click the "Menu Bar" button (on the lower right).

5. In the box labeled "Name on Menu bar," type the name for your menu, such as "Macros."

6. In the box labeled "Position on Menu Bar," click the menu (such as "Edit" or "View") after which you want your new menu to appear. (You can also click "First" or "Last.")

7. Click the "Add" or "Add After" button. (You can also remove or rename menus while you're here, but if you do so, use extreme caution. It's not easy to get things back the way they were.)

8. Click the "Close" button.

9. In the box labeled "Save changes in," select the template or document where you want your new menu to live. This will probably be your Normal template (Normal.dot), which will make the menu available to any document. You could also select another template or document, however.

10. Click the "Close" button for the "Customize" dialog.

Once you've created your menu, you can add macros to it as described in the July 11, 2001, issue of Editorium Update, which you can read here:

http://www.topica.com/lists/editorium/read/message.html?mid=1707444986

I've assumed that you're probably going to keep your new menus (and toolbars) in your Normal template, but that's not the best place to keep them, since the Normal template can become corrupted (you should back it up frequently, just in case). It's better to keep your menus and toolbars (and keyboard shortcuts and macros) in your own add-in template, as explained in the June 20, 2001, Editorium Update:

http://www.topica.com/lists/editorium/read/message.html?mid=1707194086

_________________________________________

READERS WRITE

April Karys wrote:

Our authors frequently write "the Java programing language," and just as frequently leave out the "the." I'm looking for a wildcard that will identify only the instances of this phrase that occur without the "the" and then insert it. That way I won't have to go through manually for this one correction item, but can include a wildcard with the macro that's cleaning everything *else* up. Whew. Anyway, is this possible to achieve with wildcards? Is nothing impossible to achieve with wildcards? (Will one of them make me dinner tonight?)

I responded:

As far as I know, there's no elegant (wildcard) way to do what you're describing. You just have to grit your teeth and do a two-step find-and-replace. You *can* record it in a macro, however.

To achieve what you want:

Find: Java programming language

Replace with: the Java programming language.

And then:

Find: the the Java programming language

Replace with: the Java programming language

In other words, you'll be putting an extra "the" in front of some of your "Javas" but then removing them. That will leave *all* of the occurrences looking like this:

the Java programming language

That should do the job.

In the meantime, I'll be working on some wildcards that will make duck ? l'orange. 🙂

Creating Toolbars

A few weeks ago, we talked about how to create toolbar buttons to activate your macros, but the fact is, you can create your own toolbars as well. Then you're not stuck with the toolbars that come with Microsoft Word. Here's how:

In Word 97 or later:

1. Click the "Tools" menu.

2. Click "Customize."

3. Click the "Toolbars" tab.

4. Click the "New" button.

5. In the box labeled "Toolbar name," type a name for your toolbar, such as "My Macros."

6. In the box labeled "Make toolbar available to," select the template or document where you want your toolbar to live. This will probably be your Normal template (Normal.dot), which will make your toolbar available to any document. You could also select another template or document, however.

7. Click the "OK" button.

8. Click the "Close" button.

In Word 6 or 95:

1. Click the "View" menu.

2. Click "Toolbars."

3. Click the "New" button.

4. In the box labeled "Toolbar name," type a name for your toolbar, such as "My Macros."

5. In the box labeled "Make toolbar available to," select the template or document where you want your toolbar to live. This will probably be your Normal template (Normal.dot), which will make your toolbar available to any document. You could also select another template, however.

6. Click the "OK" button.

7. Click the "Close" button.

Once you've created your toolbar, you can add macros to it as described in the June 27, 2001, issue of Editorium Update, which you can read here:

http://www.topica.com/lists/editorium/read/message.html?mid=1707286867

Macros on Menus

In our last newsletter, we talked about putting macros on toolbar buttons, but you may prefer putting them on menus instead. Here's how:

In Word 6 or 95:

1. Click the "Tools" menu.

2. Click "Customize."

3. Click the "Menus" tab.

4. In the "Categories" list, on the left, find and click "Macros."

5. In the "Macros" list, on the right, find and click the macro you want to use.

6. In the "Change What Menu" box, find and click the menu you want to use ("Edit," for example, or "Insert").

7. In the "Position on Menu" box, find and click the menu item below which you want your new menu item to appear. (You can also select "Auto" [which lets Word assign the position], "At Top," and "At Bottom.")

8. In the "Name on Menu" box, type the name of your macro as you want it to appear on the menu. (This won't change the actual name of your macro.)

9. Click the "Add" or "Add Below" button.

10. Click the "Close" button.

In Word 97 or later:

1. Click the "Tools" menu.

2. Click "Customize."

3. Click the "Commands" tab.

4. In the "Categories" list, on the left, find and click "Macros."

5. In the "Commands" list, on the right, find and click the macro you want to use and hold down the mouse button.

6. Drag the gray rectangle to the Word menu you want to use ("Edit," for example, or "Insert"). The menu will expand so you can see its entries.

7. Drag the gray rectangle to the position where you want your menu item to appear.

8. Release the mouse button. Your new menu item will appear on the menu, displaying the name of the macro.

9. In Word 97 or later, click the "Modify Selection" button or right-click the menu item you just added. A menu will appear.

10. Use the menu items to change the appearance of your new menu item until you're happy with it (see the explanations below).

11. When you're finished, click the "Close" button.

Your new menu item will appear on the menu you selected, displaying the name of the macro.

Now you can click the menu item to run your macro.

Here's an explanation of the items on the "Modify Selection" menu:

* "Delete" deletes the selected button.

* "Name" lets you change the text displayed on the menu (without affecting the name of the macro).

* "Copy Button Image" copies the icon from a selected button or menu item.

* "Paste Button Image" pastes a copied icon to the left of a selected menu item.

* "Reset Button Image" resets a menu item to its default appearance, which is blank for a new menu item to which you've assigned an icon.

* "Edit Button Image" lets you create your own icons or modify existing ones. Be careful; it's easy to spend hours playing around in here.

* "Change Button Image" lets you select one of Word's built-in icons. I frequently use the smiley face to run a quick-and-dirty macro for a particular project.

* "Default Style" displays the icon and menu name for a menu item that has both an icon and a text name.

* "Text Only (Always)" displays only the menu item's name, hiding the icon if you've assigned one. (The "Always" means this will be true even if you drag the item to a toolbar button.)

* "Text Only (In Menus)" displays only the menu item's name on the menu (but not if you drag it to a toolbar).

* "Image and Text" displays both the icon and the menu item's name.

* "Begin a Group" separates the menu item from previous menu items with a thin, gray line.

* "Assign Hyperlink" lets you use the menu item to link to a Web page, a file, a picture, or other items, but that's a topic for another day.

When you close Word, the program will ask if you want to save the changes you've made to the Normal (or other) template. In other words, do you want to keep the menu item you've added? If you do, click yes (this will also save any other changes you've made to the template).

_________________________________________

READERS WRITE

Subscriber Brian Vicary wrote:

I have read with great interest your articles concerning Word macros--in particular your more advanced series dealing with creating macros and making them available automatically via add-in templates.

As part of our business I visit our clients' sites to install software and to perform updates when necessary. We supply a Word template with predefined macros to make the use of our software easier. On networks we prefer our template to be shared so that we only have one location to update. While this can be accomplished by pointing the Word Startup path to this shared location, it is often not possible if the users already have templates in their Startup folder. Often users already have slightly different Startup templates for their own use or do not need access to a particular template.

You can add templates using the Tools, Templates and Add-Ins option, but you have to manually activate them each time you run Word.

To get round this problem this is what I do:

1. Open Word and then close the blank document that is open.

2. Go to the Tools menu and select the Macro option; from there select the Record New Macro.... option.

3. Give the macro a name appropriate to the macro--for example, AddMyMacro.

4. Click OK to begin recording the macro.

5. Click the Tools menu and select the Templates and Add-Ins option.

6. Click the Add button.

7. Navigate to where the Template document is stored on the network and select it. It should appear in the Add-ins list with a tick.

8. Click the OK button.

9. Stop recording the macro.

10. Go to the Tools menu and select the Macro option; from there select the Macros.... option.

11. Enter the name AutoExec in the Macro Name box and click the Create button. This will open the Visual Basic Editor with the new macro AutoExec.

12. In the sub for AutoExec, enter the name of the new macro you recorded above--for example, AddMyMacro.

13. Close the Visual Basic Editor.

14. Close and restart Word.

Now when Word starts, it automatically runs the macro AutoExec. This in turn runs the macro name you entered, AddMyMacro, which loads and activates the required template.

If you already have an AutoExec macro, just add a new line to it with the name of your macro. Any number of macros can be added this way, and you also have control over who loads what macros, as well as allowing them to maintain a personal Startup path.

You can also add the template in the usual manner without recording a macro, then record a macro of your activating it. The process is exactly the same, and the result is also exactly the same.

The only drawback can be the speed of the network if your macros are complex, but in practice I have not found this to be a major problem. Also, you have to get everyone to close their Word if you need to update any of the Add-on templates. However, this is true whatever method you use for sharing templates.

Hope this may be of interest to any of your readers.

Thanks very much to Brian for this useful tip.

Macros on Buttons

If you've been recording your own macros (as explained in past issues of Editorium Update), you may be interested in putting them on toolbar buttons for easy access. Here's how:

1. Make sure the toolbar you want to use is showing. (You may need to click the "View" menu, click "Toolbars," and then put a checkmark next to the toolbar you want to display.)

2. Click the "Tools" menu.

3. Click "Customize."

4. Click the "Commands" tab. (In Word 6 or Word 95, click the "Toolbars" tab.)

5. In the "Categories" list, on the left, click "Macros."

6. In the "Commands" list ("Macros" list in Word 6 or Word 95), on the right, click the macro you want to use and hold down the mouse button.

7. Drag the gray rectangle (representing a toolbar button) to a suitable position on the toolbar you want to use. (In Word 97 or later, a black "I-beam" will indicate the position of your new button.)

8. Release the mouse button. A new button will appear on the toolbar. (In Word 97 or later, it will display the name of the macro.)

9. In Word 6 or 95, click the icon you want to use, or type in the text for a text button. Then click the "Assign" button.

10. In Word 97 or later, click the "Modify Selection" button or right-click the toolbar button you just added. A menu will appear. (In Word 6 or Word 95, you can display the menu by right-clicking the toolbar button.)

11. Use the menu items to change the appearance of your button until you're happy with it (see the explanations below).

12. When you're finished, click the "Close" button.

Now you can click the button to run your macro from the toolbar.

Here's an explanation of the items on the "Modify Selection" menu (some of these are not available in Word 6 or Word 95):

* "Delete" deletes the selected button.

* "Name" lets you change the text displayed on the button (without affecting the name of the macro).

* "Copy Button Image" copies the icon from a selected button.

* "Paste Button Image" pastes a copied icon to a selected button.

* "Reset Button Image" resets a button to its default appearance, which is blank for a new button to which you've assigned an icon.

* "Edit Button Image" lets you create your own icons or modify existing ones. Be careful; it's easy to spend hours playing around in here.

* "Change Button Image" lets you select one of Word's built-in icons. I frequently use the smiley face to run a quick-and-dirty macro for a particular project.

* "Default Style" displays only the icon for a button that has both an icon and a text name.

* "Text Only (Always)" displays only the button's name, hiding the icon if you've assigned one.

* "Text Only (In Menus)" displays only the button's name if you drag the button to a menu rather than a toolbar (yes, you can do that).

* "Image and Text" displays both the icon and the button's name.

* "Begin a Group" separates the button from previous buttons with a space (in Word 6 or Word 95) or a thin, gray line.

* "Assign Hyperlink" lets you use the button to link to a Web page, a file, a picture, or other items, but that's a topic for another day.

When you close Word, the program will ask if you want to save the changes you've made to the Normal (or other) template. In other words, do you want to keep the button you've added? If you do, click yes (this will also save any other changes you've made to the template).

Creating Add-in Templates

If you've been recording your own macros, as explained in our past several newsletters, you've probably been saving them in your Normal template, where they'll be available to use with any document. The Normal template may not be the best place to save them, however. Since it's used a lot, it can become corrupt. (You should back up your Normal template frequently.) Also, saving macros in your Normal template makes it hard to keep them organized.

What's the alternative? Create your own add-in templates as a place to keep your macros. Doing so has several advantages:

1. It makes organizing your macros easy. You can keep all the macros for a particular project or task in a single add-in template.

2. It makes backing up your macros easy. Just keep copies of your templates in several locations.

3. It makes sharing your macros easy. Just give a copy of a template to a colleague or friend.

For information on how to use add-in templates, please see the past two issues of Editorium Update:

http://www.topica.com/lists/editorium/read/message.html?mid=1707012536

http://www.topica.com/lists/editorium/read/message.html?mid=1707100224

So how do you create an add-in template? Here's the way I like to do it:

1. Create a new document in Microsoft Word.

2. Save the document as a Microsoft Word template, which has a ".dot" extension. Be sure to give it a name that describes the purpose of the macros you're going to store in the template (for example, Cleanup.dot or MyProject.dot).

3. Click the "Tools" menu.

4. Click "Macro" and (in Word 97 or later) "Macros."

5. Click the "Organizer" button.

On the "Macro Project Items" tab, you'll see two windows. The name of the template you just created should be displayed above the left window, which should be empty since the template doesn't contain any macros yet. If the name of your template isn't displayed, click the drop-down list under the window and select it.

The window on the right should show the macros available in Normal.dot (as indicated above the window). If the window isn't displaying Normal.dot, click the drop-down list under the window and select it. Then, do this:

1. Select the macros in Normal.dot that you want to copy to your new template. (To select several at once, hold down the CTRL key while clicking the macro names.)

2. Click the "Copy" button. The macros should now be displayed in the left window as being in your new template. (You can also delete or rename macros if you like.)

3. Click the "Close" button.

4. Save your new template, which now contains the macros you copied to it.

You've just created your own add-in template containing your own macros.

Adding a Template Automatically

In upcoming issues of Editorium Update, I'll explain how to run macros by adding your own toolbar buttons, menu items, and keyboard combinations to Microsoft Word. If you want to get a head start, however, be sure to read today's Readers Write column, where subscriber David M Varner explains the importance of using keyboard combinations ("hot keys") and how to create them. Thanks, David!

Last week I explained how to add macros to Microsoft Word in a "global template" or "add-in." You can read last week's newsletter here:

http://www.topica.com/lists/editorium/read/message.html?mid=1707012536

The problem is, every time you start Word, you'll have to reactivate the global template before you can use its macros. Here's the procedure:

1. Click the "Tools" menu (the "File" menu in earlier versions of Word).

2. Click "Templates and Add-ins" ("Templates" in earlier versions of Word).

3. In the list of global templates and add-ins, put a checkmark in the checkbox for the template you want to use.

4. Click the "OK" button.

Wouldn't it be nice, though, if you could have Word add the template automatically? You can. Just follow this procedure:

1. Close Microsoft Word.

2. Copy the template you want to add automatically.

3. Navigate to Word's Startup folder.

4. Paste the template into the Startup folder.

5. Restart Microsoft Word.

The macros in the template should now be available for you to use, and they'll be available automatically every time you start Word.

If you don't know where the Startup folder is, here's how to find out:

1. Click the "Tools" menu (in any version of Word).

2. Click the "Options" menu item.

3. Click the "File Locations" tab.

You'll see the location of the Startup folder on the line labeled "Startup." (If you can't see the full path to the folder, click the "Modify" button.)

_________________________________________

READERS WRITE

David M Varner wrote:

Thank you for your recent information on macros. They are a big key to saving critical time on editorial tasks. I know that my assignments frequently incur midstream revisions; more accurately, frequent revisions (to subject matter as well as format) are the rule. So while macros may take a little time to create, you can zoom through those revisions so quickly that it is well worth knowing this function well. Glad to see your focus on macros.

I disagree, however, with your implicit vote for using Word's menu to implement macros. Sorting through menu items is generally somewhat awkward, especially with time constraints always looming. A pretty good short circuit for this snare is to use hot keys. Even if you prefer mousing in the menu, hot keys are a wonderful snap by comparison when considering time, and possibly crucial when a deadline is close. Having a stable of custom macros is not a bad idea either, if not inevitable.

Not only can you choose to assign hot keys while you are creating a macro, but you can also create hot keys for existing macros. I discovered the latter a couple of years ago while trying to remember the hot keys I had assigned to a certain macro. To my dismay, the answer was not to be found in the Macros dialog box--a strange oversight.

This oversight was so strange, in fact, I was convinced that macro hot-key assignments still must exist somewhere. Well, they do, and their location was not obvious, but not too far away. In short, I found them in the "Customize" dialog box. So, to find the forgotten hot keys you assigned to a macro:

1. Click "Tools" on the menu, then select "Customize" to access the "Customize" dialog box.

2. Click the "Keyboard" button to access the "Customize Keyboard" dialog box.

3. In the "Categories" field, scroll down to and select "Macros."

4. In the "Macros" field, scroll, if necessary, down to the macro you want and select it. Your assigned hot keys now appear in the "Current keys" field.

You can probably now figure out how to assign (or modify) hot keys to existing macros using the "Customize Keyboard" dialog box: Using the "Press new shortcut key" field, select "Ctrl," "Alt," and/or "Shift" keys in combination with other keyboard characters to make that hot-key assignment.

Using "Found" Macros

Over the past few weeks we've been talking about recording macros to automate repetitive tasks in Microsoft Word. You can read the newsletters here:

http://www.topica.com/lists/editorium/read/message.html?mid=1706651129

http://www.topica.com/lists/editorium/read/message.html?mid=1706748016

http://www.topica.com/lists/editorium/read/message.html?mid=1706832239

What you may not know is that there are lots of "prerecorded" macros that will do all kinds of neat things. For example, subscribers to the Word-PC email list often post useful macros. You can learn more about the list (and search the list archives) here:

http://listserv.liv.ac.uk/archives/word-pc.html

You can also find macros on the Web by searching for the keywords "microsoft word macro" in your favorite search engine.

The macros you find will probably look something like this:


Sub CopyToSpike
If WordBasic.GetSelStartPos() <> _
WordBasic.GetSelEndPos() Then 'Text is selected
WordBasic.Spike 'Add entry to spike
WordBasic.EditUndo 'Undo the cut
Else
WordBasic.MsgBox "Please select text before running this macro.", _
"No Text Selected"
End If
End Sub

That particular macro copies text to the Spike. You can learn more about it here:

http://www.topica.com/lists/editorium/read/message.html?mid=1701697740

However, you don't have to understand how the macro works in order to use it. Here's how to put it (or any other macro) into Microsoft Word so it will be available when you need it:

1. Copy the text of the macro, starting with the first "Sub" and ending with the last "Sub." If the macro doesn't have those "Sub" lines at the beginning and end, skip step 8 in these instructions.

2. Click the "Tools" menu at the top of your Microsoft Word window.

3. Click "Macro."

4. In Word 97 or later, click "Macros."

5. Make sure "Macros Available In" shows "Normal.dot."

6. Type a name for the macro in the "Macro Name" box--probably the name used after the first "Sub." For this macro, that's "CopyToSpike."

7. Click "Create."

8. Delete the "Sub [macro name]" and "End Sub" lines that Word created in the macro window. The macro window should now be completely empty.

9. Paste the macro text at the current insertion point.

10. In Word 6 or 7, click "File," then "Close," then "Yes." In Word 97 or later, click "File," then "Close and Return to Microsoft Word."

The macro is now stored in your Normal template, ready for use.

To actually run the macro, do this:

1. Click the "Tools" menu.

2. Click "Macro."

3. In Word 97 or later, click "Macros."

4. Click the name of your macro to select it.

5. Click the "Run" button. (If you wanted to delete the macro, you could press the "Delete" button instead.)

And now, some cautions:

1. Make sure the macro was created for the version of Word you are using. Macros created for Word 97 and later versions will not run in earlier versions, and you can't just paste macros written for earlier versions into Word 97 and later. Also, later versions of Word have certain features that earlier versions don't, so a macro that uses features specific to Word 2000 won't run in Word 97.

2. Try to make sure the macro comes from a reasonably reliable source.

3. Before using a macro on a real document, test it on a backup copy of the document to *make sure* it does what you need it to do.

_________________________________________

READERS WRITE

Subscriber Meg Cox wrote:

Newly committed to automating whatever I can, I tried to automate changing a word or phrase in quotes to italics and removing the quotes. But with wildcards turned on, Find wouldn't find quotation marks at all. Any idea of where I might be going wrong?

I responded (in summary):

If your document has curly quotes, use ^0147 (for opening) and ^0148 (for closing). Those are the ANSI codes for curly quotation marks. If your document has straight quotes, use " in your find and replace.

As I tested this, I used this string in the Find What box:

"(*)"

And this string in the Replace With box (formatted as italic):

1

Or, if you have curly quotes, you could find this:

^0147(*)^0148

And replace with the same thing (formatted as italic):

1

This will cause you trouble if you have unmatched quotation marks. If that's the case, you might need to do something like this:

"([!"]@)"

Or this:

^0147([!^0147]@)^0148

Recording a Complex Macro

[Editor's note: This week's article is the third in our series on macros, and I'm honored to have written it with Dan A. Wilson, proprietor of The Editor's DeskTop (http://www.editorsdesktop.com/). The example in the article is intentionally contrived. It's a nightmare task of repetitive processes. And it's long. But it's designed to teach you some things about recording macros. Dan and I hope you find it enlightening.]

The title "Recording a Complex Macro" looks intimidating, but actually *recording* a complex macro isn't really that hard. You just have to get firmly in mind what you want to do, step by step, and then do it.

~~~~~~~~~~~~

THE SCENARIO

~~~~~~~~~~~~

Suppose you have a Word document to edit--a 350-page dissertation with the title *Derived Humor: On the Roots of George Carlin's Comedy in the Works of Mark Twain.* The document has no block quotations, but it does have two hundred short Twain quotations and two hundred short Carlin quotations. The project editor wants you to make two lists of quotations so a couple of drudges can verify their accuracy. She wants the Twain quotations in one list and the Carlin quotations in another.

You'll have to create two new, blank documents. Save one with the name Twain and the other with the name Carlin. Twain will (eventually) contain all of the Twain quotations, and Carlin will (eventually) contain all of the Carlin quotations. After creating your new files, you'd have to do this (if you were doing the work by hand):

1. Scan through the dissertation file and find every Twain or Carlin quotation.

2. Select it (with its source citation).

3. Copy it to the clipboard.

4. Switch to Twain or Carlin, as appropriate.

5. Paste the quotation and source citation.

6. Hit ENTER to jump down a line so you're ready to paste the next quotation.

7. Switch back to the dissertation and hunt for the next quotation.

Whew! You'd have to select four hundred quotations, copy four hundred times, switch documents four hundred times, paste four hundred times, hit ENTER four hundred times, and switch back to your dissertation four hundred times. It would take you forever, and you'd have RSI pain before you were done.

Well, suppose we reduce that list to two tasks:

1. Select four hundred quotations (still a lot of work, but bear with us).

2. Record two macros that will do everything else when we hit their keyboard shortcuts.

That should reduce the time required for the job by at least eighty percent--maybe ninety! Not bad for a few seconds of macro recording.

Since we're going to select the quotations by hand, items 3 through 7 in the list above will make up the steps of our Twain macro:

3. Copy the quotation and citation to the clipboard.

4. Switch to Twain.

5. Paste the quotation and source citation.

6. Hit ENTER to jump down a line so you're ready to paste the next quotation.

7. Switch back to the dissertation and hunt for the next quotation.

~~~~~~~~~~~~~~~~~~~~~~~~~

RECORDING THE FIRST MACRO

~~~~~~~~~~~~~~~~~~~~~~~~~

You've got three documents open, right?

1. The dissertation itself. (We recommend that you actually create such a document to use while working through these instructions. It can include a bunch of junk text with the sample quotations from this article pasted here and there so you can actually see what happens when you record and use these macros.)

2. The empty Twain document.

3. The empty Carlin document.

You can check this by clicking the "Windows" menu on Word's menu bar, which should display a drop-down menu listing the three documents. You can switch to any of the documents by clicking its name on the menu. For now, switch to the dissertation, our starting place, and select the first Twain quotation:

"God, if you forgive my little jokes on thee, I'll forgive your great big joke on me" (ATS, p. 35).

With the quotation selected, let's record our first macro:

1. Click the "Tools" menu.

2. Click "Macro."

3. Click "Record New Macro" (in older versions of Word, click the "Record" button).

4. Type a name for the macro ("Twain") in the "Macro name" box.

5. Under "Assign macro to," click the "Keyboard" button.

6. With your cursor in the "Press new shortcut key" box, press the function key or key combination you want to use to run the macro, such as SHIFT + CTRL + T (for Twain).

7. Click the "Assign" button.

8. Click the "Close" button. The macro recording toolbar will appear with two buttons--the first to stop recording and the second to pause recording if you need to. That means the macro recorder is now recording what you do.

9. Copy the quotation and citation to the Clipboard by pressing CTRL + c.

10. Switch to the Twain document by clicking the "Windows" menu and then clicking "Twain."

11. Paste the quotation and citation by pressing CTRL + v.

12. Hit ENTER to jump down a line so you're ready to paste the next quotation.

13. Switch back to the dissertation by clicking the "Windows" menu and then clicking "Dissertation."

14. Click the "Stop" button (the button with the blue square) on the macro recording toolbar to stop recording.

~~~~~~~~~~~~~~~~~~~~~~~~~~

RECORDING THE SECOND MACRO

~~~~~~~~~~~~~~~~~~~~~~~~~~

Now let's get ready to record our Carlin macro. In the dissertation, select the first Carlin quotation:

"One tequila, two tequila, three tequila, floor" (BFP, p. 29).

With the quotation selected, let's record our second macro:

1. Click the "Tools" menu.

2. Click "Macro."

3. Click "Record New Macro" (in older versions of Word, click the "Record" button).

4. Type a name for the macro ("Carlin") in the "Macro name" box.

5. Under "Assign macro to," click the "Keyboard" button.

6. With your cursor in the "Press new shortcut key" box, press the function key or key combination you want to use to run the macro, such as SHIFT + CTRL + C (for Carlin).

7. Click the "Assign" button.

8. Click the "Close" button. The macro recording toolbar will appear with two buttons--the first to stop recording and the second to pause recording if you need to. That means the macro recorder is now recording what you do.

9. Copy the quotation and citation to the Clipboard by pressing CTRL + c.

10. Switch to the Carlin document by clicking the "Windows" menu and then clicking "Carlin."

11. Paste the quotation and citation by pressing CTRL + v.

12. Hit ENTER to jump down a line so you're ready to paste the next quotation.

13. Switch back to the dissertation by clicking the "Windows" menu and then clicking "Dissertation."

14. Click the "Stop" button (the button with the blue square) on the macro recording toolbar to stop recording.

~~~~~~~~~~~~~~~~~~

RUNNING THE MACROS

~~~~~~~~~~~~~~~~~~

Now, with both macros recorded, we're ready to go to work. Here's the procedure:

1. In the dissertation document, select a quotation, either by Twain or by Carlin.

2. If the quotation is by Twain, press SHIFT + CTRL + T.

3. If the quotation is by Carlin, press SHIFT + CTRL + C.

4. Keep going until all of the quotations are done.

When you're finished, your Twain document will have all of the Twain quotations, and the Carlin document will have all of the Carlin quotations.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

AUTOMATICALLY SELECTING THE QUOTATIONS

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Still too much work? Let's see if we can get the macros to select the quotations automatically.

We'll start with the Twain quotations. What do they have in common? They're all in quotation marks, and they're all followed by an ATS source citation in parentheses. If you've read our wildcard articles over the past few months, you know we could find (and thus automatically select) those quotations with this wildcard string:

"[!"]@" (ATS*).

What's that mean?

" is a quotation mark (which opens a quotation).

[!"]@ means "Find any additional characters except a quotation mark." (We need this to keep from including parts of other quotations.)

" is another quotation mark (which closes a quotation).

Then there's a space.

( represents an opening parenthesis. (Remember, since a parenthesis is itself a wildcard, we have to use a backslash to tell Word to treat this one as a character.)

ATS is our Twain source.

* represents any other characters following the source.

) represents a closing parenthesis.

Finally, there's a period.

Taken together, this string of characters will find our Twain quotation and others like it. And we can do the same thing with our Carlin quotations, using BFP rather than ATS in our wildcard string. So let's record our macros again, this time including this fancy way of finding and selecting them. Remember, you'll need to have three documents open:

1. The dissertation itself.

2. The empty Twain document.

3. The empty Carlin document.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RE-RECORDING THE FIRST MACRO

~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Then, with the dissertation as the active document, follow this procedure:

1. Click the "Tools" menu.

2. Click "Macro."

3. Click "Record New Macro" (in older versions of Word, click the "Record" button).

4. Type a name for the macro ("Twain") in the "Macro name" box. If Word asks if you want to replace the existing macro, click "Yes."

5. Under "Assign macro to," click the "Keyboard" button.

6. With your cursor in the "Press new shortcut key" box, press the function key or key combination you want to use to run the macro, such as SHIFT + CTRL + T (for Twain).

7. Click the "Assign" button.

8. Click the "Close" button. The macro recording toolbar will appear with two buttons--the first to stop recording and the second to pause recording if you need to. That means the macro recorder is now recording what you do.

9. Click the "Edit" menu.

10. Click the "Find" menu item.

11. In the Find dialog's "Find What" box, enter the string we discussed:

"[!"]@" (ATS*).

12. Put a checkmark in the "Use wildcards" or "Use Pattern Matching" checkbox. (You may need to click the "More" button before this is available.)

13. Click the "Find Next" button. Word will find and select the first Twain quotation and citation.

14. Click the "Cancel" button to close the Find dialog.

15. Copy the quotation and citation to the Clipboard by pressing CTRL + c.

16. Switch to the Twain document by clicking the "Windows" menu and then clicking "Twain."

17. Paste the quotation and citation by pressing CTRL + v.

18. Hit ENTER to jump down a line so you're ready to paste the next quotation.

19. Switch back to the dissertation by clicking the "Windows" menu and then clicking "Dissertation."

20. Click the "Stop" button (the button with the blue square) on the macro recording toolbar to stop recording.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RE-RECORDING THE SECOND MACRO

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Again, with the dissertation as the active document, follow this procedure:

1. Click the "Tools" menu.

2. Click "Macro."

3. Click "Record New Macro" (in older versions of Word, click the "Record" button).

4. Type a name for the macro ("Carlin") in the "Macro name" box. If Word asks if you want to replace the existing macro, click "Yes."

5. Under "Assign macro to," click the "Keyboard" button.

6. With your cursor in the "Press new shortcut key" box, press the function key or key combination you want to use to run the macro, such as SHIFT + CTRL + C (for Carlin).

7. Click the "Assign" button.

8. Click the "Close" button. The macro recording toolbar will appear with two buttons--the first to stop recording and the second to pause recording if you need to. That means the macro recorder is now recording what you do.

9. Click the "Edit" menu.

10. Click the "Find" menu item.

11. In the Find dialog's "Find What" box, enter this string:

"[!"]@" (BFP*).

12. Put a checkmark in the "Use wildcards" or "Use Pattern Matching" checkbox. (You may need to click the "More" button before this is available.)

13. Click the "Find Next" button. Word will find and select the first Carlin quotation and citation.

14. Click the "Cancel" button to close the Find dialog.

15. Copy the quotation and citation to the Clipboard by pressing CTRL + c.

16. Switch to the Carlin document by clicking the "Windows" menu and then clicking "Carlin."

17. Paste the quotation and citation by pressing CTRL + v.

18. Hit ENTER to jump down a line so you're ready to paste the next quotation.

19. Switch back to the dissertation by clicking the "Windows" menu and then clicking "Dissertation."

20. Click the "Stop" button (the button with the blue square) on the macro recording toolbar to stop recording.

~~~~~~~~~~~~

FINISHING UP

~~~~~~~~~~~~

Now you can go through the dissertation pressing SHIFT + CTRL + T to automatically select and copy the Twain quotations and then pressing SHIFT + CTRL + C to automatically select and copy the Carlin quotations. It will still take some time, but it will be *much* faster than doing all of the work by hand. Most important, by going through all of this, you've probably learned quite a bit about how to record macros and use them to simplify your work. And that's what we were *really* trying to accomplish.