Lyonizing Word: Assigning Macro Shortcut Keys

by Jack Lyon

I recently had the pleasure of doing an interview for the Chicago Manual of Style “Shop Talk” column. In the interview, I explained how to record a simple macro for transposing characters while editing.

After reading the interview, editor Kristi Hein commented:

Terrific. Next, please discuss the process of choosing a keystroke combination for your macro: not using one of the many you’ve already assigned, making it a combo that’s not too convoluted for the hands (defeating the purpose somewhat), and that you will remember among all the other keystroke combinations you’ve assigned. Therein lies the true art of automating Word effectively and efficiently.

Kristi is right, but wow, that’s a tall order. Let’s look at each requirement separately.

Not using one of the many we’ve already assigned

To not use one of the many keyboard combinations already assigned, we need to know the keystroke combinations we’ve already assigned. Here’s how to do that:

  1. Click CTRL + P to open Word’s “Print” dialog.
  2. Under “Settings,” click the dropdown list that begins with “Print All Pages.”
  3. Under “Document Properties,” click “Key Assignments.” (Also, notice the other things you might want to print, such as styles and AutoText entries.)
  4. Click the “Print” button.

You’ll get a nicely formatted document that shows all of your existing key combinations. The entries will look something like this, with the key combinations on the left and the macro names on the right:

Alt+Ctrl+Shift+S — Normal.NewMacros.ChangeStyleBasedOn
Alt+Ctrl+Shift+I — Normal.NewMacros.CheckIndexCodes
Alt+Ctrl+Shift+C — Normal.NewMacros.FixCodes
Alt+Ctrl+Shift+M — Normal.NewMacros.ParseMetadata

“And how do I assign key combinations to begin with?” you’re wondering. There are (at least) a couple of ways:

When you go to record a new macro (under View > Macro), one of your options is to assign a key combination by pressing the “Keyboard” button:

Using the keyboard option

Using the keyboard option

When you do that, you’ll see the following dialog:

The dialog for entering the key combination

The dialog for entering the key combination

If you were working with an existing macro (editing rather than recording), you’d see any existing key combinations under “Current keys.” To assign a new combination, put your cursor in the box labeled “Press new shortcut key” and, well, press a new shortcut key.

If the new key is already assigned to a macro, you’ll get a “Currently assigned to” message like this:

Currently assigned message

Currently assigned message

That’s handy because it helps you avoid accidentally overwriting a combination that you’ve already assigned (although you can overwrite one on purpose). If you don’t get that message, you’re good to go, and you can click the “Assign” button (on the lower left) and then the “Close” button (on the lower right) and then record the keystrokes that will make up your macro. (When you’re finished recording, click View > Macro > Stop Recording.)

If you want to assign a key combination to an existing macro, things get a little more complicated:

  1. Click “File > Options.”
  2. Click the “Customize Ribbon” button (on the left).
  3. Under “Choose commands from,” select “Macros” (unless you want to use one of Word’s built-in commands, which you can also do).
  4. At the bottom of the dialog, you’ll see “Keyboard shortcuts: Customize.” Click the “Customize” button and proceed as explained above.
Customizing

Customizing

But to continue…

Making it a combo that’s not too convoluted for the hands

This, of course, depends on how many fingers you have (I have ten so far) and how large or small they are, along with your native dexterity. As you can see in the picture above, I’m partial to ALT + CTRL + SHIFT, which I actually find easy to press with my left hand while pressing a letter key with my right. If that’s too convoluted for you, you might try CTRL + SHIFT or CTRL + ALT, both of which are easy to do. ALT + SHIFT is a little more difficult. You can even use plain old CTRL or ALT with another character, but that starts to encroach on Word’s built-in key combinations (like CTRL + S to save a document).

There’s another system, however, that you may not know about:

  1. Press your desired key combination.
  2. Press another key.

The result will be something like this:

Two-step key

Two-step key

See that ,”1” after the “Alt+Ctrl+Shift+M”? That means I’ve just created a two-step key combination. To run the macro, I press ALT+CTRL+SHIFT+M. Then I press 1 (the one key, all by itself). At that point (and not before), the macro will run. Pretty slick!

What that means is that you can assign all kinds of two-step combinations (letters will work as well as numbers), which gives you two characters for the mnemonic you use to remember what a combination does. That’s twice as good as one! (Unfortunately, Word won’t let you use more than two.) It also means you can create shortcuts like these:

ALT+CTRL+SHIFT+H,1 (to apply the Heading 1 style)ALT+CTRL+SHIFT+H,2 (to apply the Heading 2 style)

Or these:

CTRL + SHIFT + T,C (to transpose characters)
CTRL + SHIFT + T,W (to transpose words)
CTRL + SHIFT + T,S (to transpose sentences)
CTRL + SHIFT + T,P (to transpose paragraphs)

And so on. The mind reels at the possibilities!

Making it a combo that you will remember among all the other keystroke combinations you’ve assigned

Using two-step combinations should help with that requirement as well, but for serious keyboard junkies there’s another solution — XKeys. The company manufactures various models, from 24 keys on up to 128 keys! You can assign the keys to your macros, label the keys, color code them, and so on. The 60-key model looks like this:

The 60-key XKeys

The 60-key XKeys

Rich Adin swears by this gadget, and he’s one of the most productive copyeditors I know. Maybe you’d find it useful too.

We've met the requirements

In summary, we’ve figured out some ways to meet all of Kristi Hein’s requirements for key combinations:

  • Not using one of the many you’ve already assigned.
  • Making it a combo that’s not too convoluted for the hands.
  • Making it a combo that you will remember among all the other keystroke combinations you’ve assigned.

These may seem like small things, but small things add up to greater editing efficiency, and that means more money in your pocket and less time at work, both of which are big things. I hope this essay will help you achieve them.

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.

Lyonizing Word: From Easy to Impossible — Three Variations on a Theme

by Jack Lyon

Rich Adin just keeps on escalating the difficulty of his requests. That’s okay, because I appreciate a good challenge. Here’s his latest:

Okay, Jack, you solved the problem of reducing the number of authors from more than three down to three.

To see what Rich is talking about, please see my previous posts here: Lyonizing Word: We Can Do This the Easy Way, or . . . and Lyonizing Word: The Easy Way, Not So Easy.

Rich continues:

But there is a caveat: the list of names needs to end with “et al:”. So let me pose three more variations.

Three?! Oh, all right. Here we go:

Variation 1

How do I handle instances where the ending is punctuation other than “et al:”? For example, it could be a different punctuation mark than the colon or it could end with an author name and not “et al” (e.g., “Lyon J, Adin R, Carter TO, Jackson TT, Doe J, Smith K, Winger W:” or “Lyon J, Adin R, Carter TO, Jackson TT, Doe J, Smith K, Winger W, Hoffnagle TTP.”)

How do we handle instances where the ending is punctuation other than “et al:”? Here are Rich’s examples, all laid out for our inspection:

Lyon J, Adin R, Carter TO, Jackson TT, Doe J, Smith K, Winger W:

Lyon J, Adin R, Carter TO, Jackson TT, Doe J, Smith K, Winger W, Hoffnagle TTP.

As usual, the key is to find the “handle,” the unique elements we can grab to carry out our search. (For more on this, please see my article “What’s Your Handle?” [2003] at the Editorium Update.)

In Rich’s examples, the “handles” would have to be the colon that ends the first entry and the period that ends the second. Let’s try modifying the wildcard string from the previous post for Lyonizing Word:

([!^013]@, [!^013]@, [!^013]@, )[!^013]@([:.])

Here’s what that means:

Find any characters except a carriage return: [!^013]
repeated any number of times: @
followed by a comma
followed by a space
repeated three times
and enclosed in parentheses to form a “group.”
Then find any character except a carriage return: [!^013]
repeated any number of times: @
followed by [:.] (specifying a colon or a period) in parentheses to form a group.

And we can use the following in the “Replace With” box:

12

Here’s what that means:

Replace everything that was found
with the text represented by group 1: 1
followed by the text represented by group 2: 2

But does that actually work? Well, sort of, Here’s what we get:

Lyon J, Adin R, Carter TO, :
Lyon J, Adin R, Carter TO, .

Maybe that’s close enough, as it would now be an easy matter to search for comma space colon and replace it with a colon, and to search for comma space period and replace it with a period. But if we want to refine our search string even further, we could use this:

([!^013]@, [!^013]@, [!^013]@), [!^013]@([:.])

Here, we’ve placed the comma and space following the third name outside the parenthetical group, so they’re not included when the group is replaced by /1. That actually solves the problem, if you want to get precise, giving us a result like this:

Lyon J, Adin R, Carter TO:
Lyon J, Adin R, Carter TO.

Variation 2

Rich wrote:

How can I revise the string to work even if there is no consistency in punctuation of names? For example, suppose the names are: “Lyon, J, Adin R, Carter T.O., Jackson TT, Doe, J.; Smith K; Winger, W; Hoffnagle TTP.”

As given, this can’t be done. Why? Because we’ve lost the uniqueness of the comma “handles” that separate the names. For example, instead of this —

Lyon J,

— we have this:

Lyon, J,

And instead of this —

Smith K,

— we have this:

Smith K;

So again, as given, we can’t fulfill Rich’s request. But can we change the “as given”? Why, yes, we can!

We can search for a lowercase letter followed by a comma (at the end of a last name) and replace it with just the lowercase letter (and no comma):

Find what: ([a-z]),
Replace with: 1

We can search for a semicolon (which sometimes follows initials) and replace it with a comma:

Find what: ;
Replace with: ,

Then we can use the same wildcard string we used earlier to fulfill Rich’s request:

Find what: ([!^013]@, [!^013]@, [!^013]@), [!^013]@([:.])
Replace with: 12

You may be wondering if these wildcard strings will affect the article titles and journal names and not just the author names. The answer is, it depends. I’m assuming, for example, that the article titles and journal names don’t include commas (just for purposes of illustration). But if they do, you may have to get creative. Let’s take this as an example:

Levy, D, Ehret G, Rice K, Verwoert G, Launer L, Dehghan A, Glazer N, Morrison A, Johnson A, Aspelund T, Ganesh S, Chasman D: Genome-wide association study of blood pressure, stress, and hypertension. Nature 2009, 41(6): 677-687.

See that comma after “Levy”? Above, we got rid of it with the following strings:

Find what: ([a-z]),
Replace with: 1

But notice that this will also remove the commas after “pressure” and “stress” in the article title, which we don’t want to do. The solution, again, comes down to handles. What do we have that sets off the article title and journal name? In this example, they’re preceded by the colon after the author names (“Chasman D:”) and followed by a carriage return (at the end of the citation). So here’s a rather sneaky solution: Search for a colon followed by anything that isn’t a carriage return until you come to a carriage return. Then replace whatever was found with itself (^&) formatted as Hidden:

Find what: :[!^013]@^013
Replace with (use Hidden formatting): ^&

If you don’t know how to replace using formatting, here’s the secret:

1. Put your cursor in the “Replace with” box.
2. Click the “More” button if it’s showing.
3. Click the “Format” button on the bottom left.
4. Click “Font.”
5. Put a check in box labeled “Hidden.”
6. Click the “OK” button.

Notice that you can replace with all kinds of formatting: styles, paragraph alignment, and so on. You can also use formatting in the “Find what” box! This is really powerful stuff, and if you didn’t know about it before, now you can add it to your bag of tricks.

At any rate, with the article titles and journal names formatted as Hidden, you can make sure they actually are hidden by clicking the “Show/Hide” button (with the pilcrow icon: ¶) on Word’s “Home” tab. Then run your find and replace to remove commas from last names:

Find what: ([a-z]),
Replace with: 1

Finally, unhide the article titles and journal names (after using “Show/Hide” to display them):

Find what: (Hidden formatting)
Replace with: (Not Hidden formatting)

At that point, the commas will be gone from the authors’ last names but preserved in the article titles and journal names.

By the way, if you’re working on a Macintosh, you’ll find that Word doesn’t recognize the standard code for a carriage return (^013) while searching with wildcards. But never fear: you can still do what you need by “escaping” the code with a backslash and treating it as a range using square brackets. In other words, use this:

[ˆ013]

To specify not a carriage return, use the following:

[!ˆ013]

Variation 3

Rich wrote:

How can I adapt the wildcard string to delete those in excess of a certain number? For example, I have one client who wants up to ten author names listed and “et al” used only for names eleven and following. I would like to specify how many names I want retained and replace the excess with “et al.” For example, if there are fifteen names, delete the last five if ten are okay and replace them with “et al.”

Theoretically, we could do that as long as there’s a “handle” that marks the end of the names. Let’s take this example:

Levy D, Ehret G, Rice K, Verwoert G, Launer L, Dehghan A, Glazer N, Morrison A, Johnson A, Aspelund T, Ganesh S, Chasman D: Genome-wide association study of blood pressure and hypertension. Nature 2009, 41(6): 677-687.

There are actually twelve names there, so we want to keep the first ten and replace the last two with “et al.” What’s our handle? The colon after the last name (“Chasman D:”) and before the article’s title. So let’s try an expansion of the wildcard search string we used in the previous post for Lyonizing Word. Instead of grouping three comma-separated names, we’ll group ten:

Find what: ([!^013]@, [!^013]@, [!^013]@, [!^013]@, [!^013]@, [!^013]@, [!^013]@, [!^013]@, [!^013]@, [!^013]@,)[!^013]@(:)
Replace with: 1 et al.2

That would work if Word could handle it. But if you try it, Word will complain: “The Find What text contains a Pattern Match expression which is too complex.” So now what? Honestly, I’m not sure. I tried several other possibilities, none of which were successful. So if you, Gentle Reader, have any ideas about how to accomplish this seemingly impossible feat, I’d love to hear them.

Wildcard searching can’t do everything, but it can do an awful lot. As I’ve said before, after all these years of editing, wildcard searching is the tool I rely on the most. I encourage you to invest the time needed to learn to use this tool, which will repay your efforts many times over. A good place to start is my free paper “Advanced Find and Replace in Microsoft Word.”

I hope you’ll also watch for my forthcoming Wildcard Cookbook for Microsoft Word. I’m still trying to find more real-life examples for the book, so if you have some particularly sticky problems that might be solved using a wildcard search, I hope you’ll send them my way. Maybe I can save you some work and at the same time figure out solutions that will help others in the future. Thanks for your help!

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.

For other Lyonizing Word essays at An American Editor, Lyonizing Word at AAE.

Lyonizing Word: The Easy Way, Not So Easy

by Jack Lyon

After publishing my last article, Lyonizing Word: We Can Do This the Easy Way, or . . ., Rich Adin, An American Editor, wrote:

As written, your wildcard find and replace reduces four names to three if “et al:” is the ending characteristic. How do you write it so that it can handle any number of names, say up to seven?

Good question, and a nice challenge for a wildcard search. Let’s say we have citations with strings of names like this:

Lyon J, Adin R, Carter TO, Jackson TT, Doe J, Smith K, Winger W, et al: blah blah blah

That’s seven names, but let’s see if we can make a wildcard string that will find any number of names and cut them down to three. My first impression is that this might be difficult or even impossible. But let’s try the following wildcard string:

([!^013]@, ){3}([!^013]@, ){1,}(et al:)

Here’s what that means:

Find any character except a carriage return: [!^013]
repeated any number of times: @
followed by a comma
followed by a space
and enclosed in parentheses to form a “group.”
Do that three times in a row: {3}
Find using the same group: ([!^013]@, )
if it occurs once or more (as indicated by the comma): {1,}
followed by “et al:” in parentheses to form a group.

There’s just one problem: It doesn’t work. And that’s how it often is with wildcards — sometimes you have to fiddle around to get the result you want; trial and error are key. So let’s see if we can find just three instances of text using our group:

([!^013]@, ){3}

That doesn’t work either. What in the world is going on here? Let’s try using the group three times in a row:

([!^013]@, )([!^013]@, )([!^013]@, )

That does work. So why not this?

([!^013]@, ){3}

Could it be that {3} doesn’t apply to the wildcard pattern ([!^013]@, ) itself but to the first instance of text that pattern finds? In other words, would that wildcard string  find the first three names in a citation like the following?

Lyon J, Lyon J, Lyon J, Lyon J, Lyon J, Lyon J, Lyon J, et al: blah blah blah

Sure enough, that works! So we’ve just learned something new about wildcard searches. For clarity, I’ll restate it here:

Specifying how many times to find something (using {3}, for example) doesn’t apply to the wildcard pattern it follows but to the first instance of text that pattern finds.

Unfortunately, that means we need to work out a different approach to our original problem. How about this?

([!^013]@, [!^013]@, [!^013]@, )([!^013]@, ){1,}(et al:)

Here’s what that means:

Find any character except a carriage return: [!^013]
repeated any number of times: @
followed by a comma
followed by a space
repeated three times
and enclosed in parentheses to form a “group.”
Find using the same group: ([!^013]@, )
if it occurs once or more (as indicated by the comma): {1,}
followed by “et al:” in parentheses to form a group.

But no, that doesn’t work either! Why not? Oh, yeah, because of that {1,}. As we discovered earlier:

Specifying how many times to find something (using {3}, for example) doesn’t apply to the wildcard pattern it follows but to the first instance of text that pattern finds.

Well, okay, then. We’ll stop using numbers (such as {1,}) to specify how many times a pattern should be repeated (at least for our current purposes). Let’s try this instead:

([!^013]@, [!^013]@, [!^013]@, )[!^013]@(et al:)

Here’s what that means:

Find any characters except a carriage return: [!^013]
repeated any number of times: @
followed by a comma
followed by a space
repeated three times
and enclosed in parentheses to form a “group.”
Then find any character except a carriage return: [!^013]
repeated any number of times: @
followed by “et al:” in parentheses to form a group.

Well, son of a gun; that actually works. So now we can use the following in the “Replace With” box:

12

Here’s what that means:

Replace everything that was found
with the text represented by group 1: 1
followed by the text represented by group 2: 2

Group 1, you’ll remember, was this:

([!^013]@, [!^013]@, [!^013]@, )

It finds the first three names in our citations. And group 2 was this:

(et al:)

It finds the end of our citations.

And so, finally, we’ve succeeded in fulfilling Rich’s original request:

As written, your wildcard find and replace reduces four names to three if “et al:” is the ending characteristic. How do you write it so that it can handle any number of names, say up to seven?

Sometimes the easy way isn’t so easy. Nevertheless, it’s almost always worth pursuing. In Rich’s case, it reduced his editing time from hours (removing extraneous names by hand) to minutes (removing the names with a wildcard find and replace). It also gave Rich a wildcard search that he can save in his fabulous EditTools software for use with future projects. And it provided a deeper and clearer understanding of how to use wildcard searches.

After all these years of editing, wildcard searching is the tool I rely on the most. I encourage you to invest the time needed to learn to use this tool, which will repay your efforts many times over. A good place to start is my free paper “Advanced Find and Replace in Microsoft Word.”

I hope you’ll also watch for my forthcoming Wildcard Cookbook for Microsoft Word. I’m still trying to find more real-life examples for the book, so if you have some particularly sticky problems that might be solved using a wildcard search, I hope you’ll send them my way. Maybe I can save you some work and at the same time figure out solutions that will help others in the future. Thanks for your help!

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.


 

Looking for a Deal?

You can buy EditTools in a package with PerfectIt and Editor's Toolkit at a special savings of $78 off the price if bought individually. To purchase the package at the special deal price, click Editor's Toolkit Ultimate.

Lyonizing Word: We Can Do This the Easy Way, or . . .

We Can Do This the Easy Way,
or We Can Do This the Hard Way

by Jack Lyon

American Editor Rich Adin called me recently with a puzzle. He was editing a list of citations that looked like this:

Lyon J, Adin R, Poole L, Brenner E, et al: blah blah blah.

But his client wanted the citations to look like this:

Lyon J, Adin R, Poole L, et al: blah blah blah.

In other words, many of the citations included one author name too many; the client wanted a limit of three rather than four. And there were hundreds of citations. Rich really didn’t want to remove the superfluous names by hand; it would have taken hours to do, and hours are money. And so, Rich queried, “Is there a way to remove the fourth name automatically?”

There’s nearly always a way. Rich had already tried using a wildcard search, but without success. Microsoft Word kept telling him, “The Find What pattern contains a Pattern Match expression which is too complex.”

The Too-Complex Find What

I’m not sure what wildcard search Rich tried to use, but it might have looked like this:

Find what:

([A-Z][a-z]@ [A-Z], )([A-Z][a-z]@ [A-Z], )([A-Z][a-z]@ [A-Z], )([A-Z][a-z]@ [A-Z], )(et al:)

Replace with:

1235

That’s definitely too complex for Word to handle. Here’s what it means:

Find a capital letter ([A-Z])
followed by a lowercase letter ([a-z])
repeated any number of times (@)
followed by a space
followed by a capital letter ([A-Z])
followed by a comma
followed by a space
with all of that in parentheses to form a “group.”

All of that is repeated three more times, then followed by “et al:” in parentheses to form a group.

The “Replace with” string tells Word to replace what it finds with the contents of groups 1, 2, 3, and 5 — in other words, with the first three names followed by “et al:”.

What’s the Handle?

If Word could handle it, that should work. But Word can’t handle it, so we’ll need to simplify. So we ask ourselves, “What, besides letters, do all of the names have in common?” In other words, “What’s the handle? What can we grab onto?” Well, that’s easy — each name is followed by a comma and a space. That’s our handle!

(For more on this, please see my article "What’s Your Handle?" (2003) at the Editorium Update.)

The Find That Works

The handle means we can simplify our wildcard search string to something like this:

Find what:

([!^013]@, [!^013]@, [!^013]@, )[!^013]@, (et al:)

Replace with:

12

Here’s what that means:

Find any characters except a carriage return ([!^013])
repeated any number of times (@)
followed by a comma
followed by a space
with all of that repeated three times
and enclosed in parentheses to form a “group.”
Then it’s repeated one more time, ungrouped
and followed by “et al:” in parentheses to form a group.

The “Replace with” string tells Word to replace what it finds with the contents of groups 1 and 2 — in other words, with the first three names (group 1) followed by “et al:” (group 2). The fourth name is simply ignored.

To Group or Not to Group Using Parens

Rich ran the new find and replace, then replied, “Thanks, Jack, that works like a charm. Why isn’t the second ‘group’ grouped, that is, in parentheses? I thought that was necessary.”

I replied, “No, it’s not necessary. You group only the items that you want to reference (by 1, 2, etc.) in the ‘Replace with’ box. You could group the other item, in which case you would use ‘13’ in the ‘Replace with’ box. But there’s no need to do so.”

Note that this method of finding the names offers another advantage. Not only will it find names that look like this:

Lyon J,

it will also find names that look like this:

Lyon JM,

or even this:

Lyon JMQ

It will even find names like this:

Thaler-Carter Ruth,

or this:

Harrison G.B.H.,

In fact, it will find anything (except a carriage return) followed by a comma and a space.

Why the Carriage Return?

“Why,” you may be wondering, “specify anything but a carriage return? Why not specify letters instead?” Well, we could have done that, using something like this:

Find what:

([A-z ]@, [A-z ]@, [A-z ]@, )[A-z ]@, (et al:)

Replace with:

12

That means:

any capital or lowercase letter or space ([A-z ])
repeated any number of times (@)
followed by a comma
followed by a space
And so on.

Such a wildcard string would find names like this:

Lyon J,

but not this:

Thaler-Carter R,

Yes, we could add a hyphen to our string, but then we start to wonder about other characters we might need to include, and then things get complicated again. And besides, it’s true that we don’t want to include carriage returns in our search, so it makes sense to exclude them. If we tried to simplify too far, we might use this:

Find what:

(*, *, *, )*, (et al:)

Replace with:

12

The problem with using the asterisk wildcard (*) is that it finds any character any number of times, including tabs, spaces, carriage returns, and everything else you can think of. Sometimes that’s useful, but more often it just leads to confusion. We want to keep things simple but not too simple.

Why Wildcard

To return to our original problem: Rich could have removed all those extra names one at a time, by hand, which is doing it the hard way and eats into the profit line — remember that time is money. Microsoft Word includes powerful tools for doing things the easy way, so why not learn them and use them? If you’ve read this far, you’re doing that, so congratulations.

If you’d like to learn more about how to use wildcard searches, you can download my free paper “Advanced Find and Replace in Microsoft Word.” Working through the paper requires some thought and effort, but the payoff is huge.

Coming Soon

I hope you’ll watch for my forthcoming Wildcard Cookbook for Microsoft Word. I’m still trying to find more real-life examples for the book, so if you have some particularly sticky problems that might be solved using a wildcard search, I hope you’ll send them my way. Maybe I can save you some work and at the same time figure out solutions that will help others in the future. Thanks for your help!

For EditTools Users

If you are a user of EditTools, you can manually create the find and replace strings in the Wildcard Find & Replace macro and then save the macro for future use. However, to do so you need to enter the Find string slightly differently:

Find Field #1: [!^013]@, [!^013]@, [!^013]@,
Find Field #2: [!^013]@,
Find Field #3: et al:

Note that you omit the parens for grouping because EditTools automatically inserts them, which means that you break the string into its group components. (IMPORTANT: Be sure to include in Find Fields 1 and 2 the ending space, i.e., the space following the final comma, which is not visible above.)

Because EditTools treats each of the three fields as a group, your Replace string is:

Replace Field #1: 1
Replace Field #2: 3

After manually entering the information in each of the fields, click Add to WFR Dataset and save this macro for future use. Next time you need it, just click Retrieve from WFR Dataset, retrieve this string, and run it. That is one of the advantages to using EditTools' Wildcard Find & Replace — you can write a wildcard macro once and reuse it as many times as you need without having to recreate the macro each time.

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.

Looking for a Deal?

You can buy EditTools in a package with PerfectIt and Editor's Toolkit at a special savings of $78 off the price if bought individually. To purchase the package at the special deal price, click Editor's Toolkit Ultimate.

 

Lyonizing Word: Shifting Styles

Shifting Styles

by Jack Lyon

In its undying efforts to be “helpful,” Microsoft Word can cause no end of problems. Among the worst of these are what I call “shifting styles,” which can change the formatting of your document without your consent and sometimes without your knowledge. Yow! I know of five ways this can happen. Here’s how to identify and fix each one.

Automatically Update Document Styles

The Problem

You go through your document, fine-tuning its style formatting to the peak of perfection. Then you carefully save your document for posterity. A week later, you reopen your document. What the…? All of your styles have shifted back to their original formatting. You’ll have to do all of that work over again! And how can you be sure it will stick?

The Solution

  1. Open the document.
  2. Click the Developer tab. (If you don’t have such a tab, click File > Options > Customize Ribbon. In the big window on the right, put a check in the box labeled “Developer. Then click the OK button.)
  3. Click the Document Template icon.
  4. Remove that dadburned checkmark in the box labeled “Automatically update document styles.”
  5. Resave your document.

The next time you open the document, your exquisite style formatting will remain intact.

So what’s the point of the “Automatically update document styles” feature? Well, let’s say that your boss just loves to tinker with the look of your company’s forms and stationery, mandating Helvetica one week and Comic Sans the next. If you turn on “Automatically update document styles” for every company document you create, changing the formatting is a snap. Just open the template on which the documents are based, modify the styles, and resave the template. The next time you open one of those documents, its styles will automatically update to match those of the template.

It’s a slick feature, as long as you know when — and when not — to use it.

Automatically Update Styles

The Problem

You’ve just opened a new document from a client, and you italicize the first paragraph, which is a short quotation introducing the chapter. But suddenly all of the chapter text is italicized. What in the world is going on?

You’ve just bumped into Word’s “Automatically update” feature for styles. (This feature affects only the styles in the current document, making it different from the “Automatically update document styles” feature discussed above.) If you don’t know about the “Automatically update” feature, you can spend hours trying to adjust formatting, only to have everything in sight messed up beyond belief.

The Solution

  1. Click the Home tab.
  2. In the Styles section of the Ribbon, right-click the style (such as Heading 1) applied to your text. (If you can’t see the style, click the little gray button under the Change Styles icon to open the Styles task pane.)
  3. Click Modify.
  4. Near the bottom right of the dialog, remove the checkmark from the box labeled “Automatically update.”
  5. Click the “OK” button.

Now when you modify some formatting in your document, you’ll change only the local selection and not everything that’s formatted in the same style. But really, you should avoid using directly applied formatting anyway. Using paragraph and character styles is much more efficient — the True Way — and avoids a multitude of problems.

So what’s the point of the “Automatically update” feature? It allows you to modify styles without drilling down, down, down through multiple menus. Well hey, that’s good! It means you can change formatting directly, see the result immediately, and have the styles updated automatically to reflect that formatting. Pretty neat!

So here’s my recommendation:

  • If you’re designing a document, use the “Automatically update” feature with a bunch of junk text to set your styles exactly the way you want them (be sure to select the whole paragraph before changing the format). Once you’ve got them set, turn off “Automatically update.” Then copy the styles to your real document, or save the junk document as a template that you attach to your real document.
  • If you’re writing or editing a document, make sure the “Automatically update” feature is turned off.

Styles Based on Styles

The Problem

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.

The Solution

If you don’t want your style to be based on another style, do this:

  1. Click the Home tab.
  2. In the Styles section of the Ribbon, right-click the style (such as Heading 1) applied to your text. (If you can’t see the style, click the little gray button under the Change Styles icon to open the Styles task pane.)
  3. Click Modify.
  4. In the “Style based on” dropdown list, select “no style” (the first option in the list).
  5. Click the OK button.

Problem solved.

But not so fast. Actually, this feature can be quite useful, as long as you know what’s going on.

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 Home tab.
  2. In the Styles section of the Ribbon, right-click the style (such as Heading 2) applied to your text. (If you can’t see the style, click the little gray button under the Change Styles icon to open the Styles task pane.)
  3. Click Modify.
  4. In the “Style based on” dropdown list, click the style (Heading 1, for example) on which you want to base the current style.
  5. Click the OK 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 inherited from 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.

You can use this feature 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.

AutoFormat Headings

The Problem

You’re typing along, and suddenly the short line you entered a couple of paragraphs earlier has turned big and bold. Who does it think it is, anyway? When you investigate, you discover that the line has somehow been formatted with Word’s Heading 1 style.

You’ve just discovered one of the wonders of Word’s AutoFormat feature, which should be firmly beaten into submission before it takes over your whole document.

The Solution

  1. Click File > Options > Proofing.
  2. Click the button labeled “AutoCorrect Options.”
  3. Click the tab labeled “AutoFormat As You Type.”
  4. Under “Apply as you type,” remove the check from the box labeled “Built-in Heading Styles.”
  5. Click the OK button.
  6. Click the next OK button.

Now if you type a line of text ending in a carriage return but without ending punctuation (which, by the way, seems to be the defining factor here), Word will no longer see it as a heading and will no longer try to format it as such.

Define Styles Based on Your Formatting

The Problem

As explained above, you’ve turned off the AutoFormat option to apply headings as you type, but you still get automatic formatting. If that’s the case, you may still have the last “AutoFormat As You Type” option turned on. It’s labeled “Define styles based on your formatting,” and Microsoft explains its function like this: “Create new paragraph styles based on the manual formatting you apply in your documents. You can apply these styles in your document to save time and to give your documents a consistent ‘look.’”

The idea that Word is creating new styles as I work just gives me the heebie-jeebies.

The Solution

  1. Click File > Options > Proofing.
  2. Click the button labeled “AutoCorrect Options.”
  3. Click the tab labeled “AutoFormat As You Type.”
  4. Under “Apply as you type,” remove the check from the box labeled “Define styles based on your formatting.”
  5. Click the OK button.
  6. Click the next OK button.

Problem solved — no more proliferation of unwanted styles.

The whole issue with all of these problems is one of control. How much “help” do you want Microsoft Word to give you? If you’re editing, your answer may be “none,” because editors need to have complete control over what’s happening, and they can’t have Word introducing changes they may not even be aware of. When I’m editing, I disable all of these features. If you’ve been suffering from the madness of shifting styles, maybe you’ll want to do the same.

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.

Lyonizing Word: The Right Tool for the Job

The Right Tool for the Job

by Jack Lyon

The sardine fork. The oyster ladle. The cake breaker. The butter pick. Those persnickety Victorians had a utensil for everything! You’ll find some interesting examples here:

Was all of that really necessary? I still eat the occasional sardine, and an ordinary table fork gets the job done. But I’m willing to bet that if I ever tried an actual sardine fork, I’d immediately realize the advantages of doing so. If I ever needed to ladle out oysters, I’ll bet an oyster ladle would be the perfect tool for the job.

The Wrong Tools

Every editor I know uses Microsoft Word. It’s the standard solution, the default program, the accepted tool for word processing. But is it the best tool for editing? Out of the box, it’s not. It has too many features that editors don’t need, and they’re always getting in the way.

When you’re editing, how often do you use SmartArt? How about WordArt? Page color? No? Then why not get rid of them? Why not turn Word into a lean, mean, editing machine? You can do this by customizing Word’s Ribbon. To do so, click File > Options > Customize Ribbon.

On the right side of your screen, you’ll now see a list of the Ribbon tabs and groups, like this:

Jack Lyon Graphic 1

Notice that I’ve unchecked the “Mailings tab.” I don’t want it showing because it’s something I never use. (Note: If you use macros, you should probably keep the “Developer” tab; it allows access to those macros and also allows you to load various document templates that may include macros.)

Now see that dropdown list at the top of the window? The one that says “Main Tabs”? Click it and select “All Tabs.” Now you’ll have many more options to uncheck:

Jack Lyon Graphic 2

Do you really need Chart Tools? Drawing Tools? Picture Tools? If not, make them go away. (Don’t worry—if necessary, you can always get them back again.)

So far, we’ve been removing whole groups of features at once, but you can also remove individual items from a group—if they are items you’ve previously added. Unfortunately Microsoft won’t let you remove the individual default features they think you need to have.

The Right Tools

The other problem with Microsoft Word is that it doesn’t have enough of the tools that editors need—at least not by default. Here again, the solution is to customize the Ribbon. Again, click File > Options > Customize Ribbon. This time, look at the window on the left. In the top dropdown box, select “Commands Not in the Ribbon.” Very interesting!

Jack Lyon Graphic 3

These are Word’s “hidden” commands, the features I encouraged you to explore in my previous article “Let’s Go Spelunking!”

Using the buttons in the window, you can add these features to the groups of your choice on Word’s Ribbon. You can even add your own custom tabs and groups by clicking the buttons labeled “New Tab” and “New Group.” How about adding a tab called something like “Editing Tools,” with all of the features you need for editing? If you’re also a writer, you could add a tab called “Writing Tools.” Some of the features would be different; some of the features would be the same. There’s nothing wrong with having certain features duplicated between tabs or groups, if that makes your work easier.

You can select other features by clicking the dropdown list and selecting “All Commands.” You can even select macros and add them to the Ribbon.

Add-In Tools

Unfortunately, even with the wealth of features that Word provides, there are other editing tools that Word doesn’t provide. For example, how often do you need to transpose two words? Two characters? How much time do you spend lowercasing articles and prepositions in titles? How often do you have to reach for the mouse in order to apply a style?

This is where add-in programs come in. “What’s an add-in program?” you ask. An add-in program is a Microsoft Word template that includes custom macros, Ribbon items, and keyboard shortcuts created specifically for a particular task—kind of like those Victorian utensils. As the name suggests, an add-in isn’t an independent piece of software; it actually works inside Microsoft Word, adding new features that then seem to be an integral part of Word. This isn’t some kind of hack, by the way; Microsoft Word was designed to support such add-ins, which is what makes them possible.

I’m partial to my own add-ins, of course, the ones I sell on the Editorium website. I’m really an editor, not a programmer, and I created these add-ins to make my own work easier. But I think you might like them too.

One of my favorites is the “Cap Title Case” feature in Editor’s ToolKit. When I’m working on a manuscript and come across a title like “The Ghost In The Machine,” or worse, “THE GHOST IN THE MACHINE,” I select the title and press the F5 function key (which activates the “Cap Title Case” feature). Like magic, the title is now capped like this: “The Ghost in the Machine.”

If I want to transpose two words, I put my cursor anywhere in the second word and press the F11 key. To transpose two characters, I press F12. Rather than reaching for the mouse to apply a style, I press F5, which puts all of the styles at my fingertips. And as they say on television, there’s much, much more!

All of these are small things, but those small things add up to big savings in time. And when you’re editing for a living, time is money.

So how much is an add-in actually worth? If it saves you an hour on a single project, it’s probably paid for itself. On the next project, it pays for itself again. And on and on, into the future. Seldom does such a small investment reap such big rewards.

Yes, this is a sales pitch, but I genuinely want you to succeed. That’s why I promote other add-ins like Rich Adin’s EditTools and Daniel Heuman’s PerfectIt.

These tools can make a real difference in how efficiently you work and how much money you can make. With that in mind, why not get them all, at a very special price?

Don’t think of these tools as an expense; think of them as an investment. Then the next time you need an editing tool, you’ll have it—and it will be the right tool for the job. Instead of dishing out tomato slices with a fork, you can use a tomato spoon! Instead of picking up bacon with your fingers, you can use a bacon fork! Using the right tool for the job makes all the difference in the world.

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.

Lyonizing Word: Finding and Replacing Upper- and Lowercase

Finding and Replacing Upper- and Lowercase

by Jack Lyon

Rich Adin, the proprietor of this blog, recently sent me an interesting question. He wrote:

I need a wildcard find and replace, assuming it can be done by wildcards, that searches for the following

Abrams: alpha
booby: alarm

and replaces it with

Abrams: Alpha
booby: Alarm

That is, the first letter after the colon and space is changed from lowercase to uppercase. I know I can do this by macro, and I have one that will do it, but I would like to do it by wildcard so I can make it part of a script I run.

Unfortunately, there's no good way to do that. Using a wildcard search, we can find any lowercase letter (preceded by a colon and space) by using the following string in the Find What box:

: [a-z]

But in the Replace With box, we should use—what? We can't use the following string because it doesn't specify what the replacement letter should be:

: [A-Z]

In fact, if we try that, Word will simply replace what was found with the string itself, giving us this:

Abrams: [A-Z]lpha
booby: [A-Z]larm

There is, however, a rather sneaky (but ultimately unsatisfactory) workaround. We can replace the lowercase letter with itself formatted as uppercase. Here's how:

1. Press CTRL + H to bring up Word's Replace dialog.
2. If the More button is available, click it.
3. Put a check in the box labeled "Use Wildcards."
4. In the Find What box, enter this:

: [a-z]

5. In the Replace With box, enter this

^&

That's the magic code that tells Word to replace what was found with what was found. In other words, if Word finds ": a" it should replace it with ": a" (the same thing it was searching for). You'll see why in just a minute.

6. Make sure your cursor is in the Replace With box.
7. Click the Format button at the bottom left of the Replace dialog.
8. Click Font.
9. Put a check in the box labeled "All caps."
10. Click OK.
11. Click "Replace All."

That should do the trick; all of our lowercase letters following a colon and space are now formatted as "All caps." The reason I said earlier that this is "ultimately unsatisfactory" is that those letters are not actually uppercase; they merely look as if they're uppercase because of their formatting.

In some situations, that may be good enough. But if your document is destined to be published in a format other than Microsoft Word, it may not be good enough, as formatting may change and, like Cinderella at the stroke of midnight, our "uppercase" letters may revert to their true lowercase selves. (How often do we get to use a fairytale allusion in technical writing?)

The only real solution is to use a macro, like this one:

Sub ReplaceLowercaseWithCaps()
Selection.HomeKey Unit:=wdStory 'Position cursor at top of document
Selection.Find.ClearFormatting 'Clear any
Selection.Find.Replacement.ClearFormatting
With Selection.Find

.Text = ": [a-z]" 'Search for colon and space followed by lowercase letter
.Replacement.Text = "" 'Leave empty--the macro will replace the text later
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True 'Specify a wildcard search

End With
Selection.Find.Execute 'Execute the search
While Selection.Find.Found 'While the search is successful

Selection = UCase(Selection) 'Uppercase what was found
Selection.MoveRight 'Move out of the selection
Selection.Find.Execute 'Try, try again

Wend 'End the "While" loop
End Sub

I've added comments to explain what's going on, but the really pertinent line is this one:

Selection = UCase(Selection) 'Uppercase what was found

When Word finds a colon and space followed by a lowercase letter, it selects the colon, space, and letter (naturally, because it found them), so those are the "Selection." The macro then converts those characters to uppercase using the "UCase" function; it sets the Selection as the uppercased version of the Selection, if you see what I mean.

After that, the macro moves to the right so the text is no longer selected. Then it again executes the Find in an effort to locate the next instance of colon, space, and lowercase letter, if one exists.

And yes, for the sake of simplicity, the colon and space are uppercased here as well as the letter. What's an uppercased colon? A colon. What's an uppercased space? A space. If we wanted to, we could modify the macro to handle each of those separately, but why bother when the result is the same? Virtue in simplicity.

Note that we could do the inverse of this, if we needed to, finding any uppercase letter and lowercasing it. To do so, we'd use ": [A-Z]" for the search string, and we'd modify Selection with the LCase function rather than UCase.

I wish that Microsoft had included a better way to handle this. Even though Microsoft didn't, we now have a way to accomplish what we need to do.

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.

________

How to Add Macro to Word & to the QAT

Here’s how to put this macro (or any other) 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.”
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  4. Type a name for the macro in the “Macro name” box — probably the name used after the first “Sub.” For this macro, that’s “ReplaceLowercaseWithCaps.”
  5. Click the “Create” button.
  6. Delete the “Sub [macro name]” and “End Sub” lines that Word created in the macro window. The macro window should now be completely empty (unless you already have other macros in there).
  7. Paste the macro text at the current insertion point.
  8. Click “File,” then “Close and Return to Microsoft Word.”

To actually use the macro:

  1. Place your cursor at the beginning of your document.
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  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.)

Here’s how to put the macro on Word’s QAT (Quick Access Toolbar):

  1. Locate the QAT (it’s probably on the top left of your screen either above or below Word’s Ribbon interface).
  2. Right-click the QAT.
  3. Click “Customize Quick Access Toolbar.”
  4. Under “Choose commands from:” click the dropdown list and select “Macros.”
  5. Find and select your macro in the list on the left.
  6. Click the “Add” button to add it to the QAT.
  7. Click the “OK” button to finish.

Lyonizing Word: Formatting with Macros

Formatting with Macros

by Jack Lyon

Most users of Microsoft Word format text by selecting a paragraph and then applying a font. More advanced users apply a style. Here’s why:

  1. Styles are easier to use than direct formatting. Once you have the style set up (with, say, 12-point Arial bold, condensed by 1 point, left justified, with 24 points of leading above and 12 points of leading below), you can apply that style with a single click. But if you apply the same formatting without using a style, you’ll have to make a dozen clicks for each heading. If your document has 50 headings, that’s hundreds of clicks—versus 50 clicks if you use a style.
  2. If you need to change the formatting of, say, level-2 headings, you can simply modify the style rather than tediously selecting each heading and applying a different font. Modify the style, and the formatting of all those headings is automatically changed.

But there is a way to handle formatting that is even more powerful—by using macros.

Suppose that you’ve dutifully applied styles to the various parts of a document, but then your client asks you to change the font—everywhere in the document—from Times New Roman to Adobe Garamond. (No, you should not just select the whole document and apply Adobe Garamond. Why? Because that simply “paints over” the real formatting that is still there in the styles, and it will almost certainly lead to inconsistent formatting somewhere down the line.) You could manually modify each style, but if there are dozens of styles in use, there is a better way. That way is a macro, like this one:

Sub SetFontInAllStyles()
Dim aStyle As Style
For Each aStyle In ActiveDocument.Style
aStyle.Font.Name = "Adobe Garamond"
Next
End Sub

Well, that was easy. Let’s look at each line of the macro (excluding the first and last lines, which simply define the beginning and end of the macro).

Dim aStyle As Style

This line defines (dimensions) a variable, aStyle (which name I just made up), as a style. At one point as the macro runs, aStyle might represent the style Heading 1. At another point it might represent Heading 3. But it will always represent a style.

For Each aStyle In ActiveDocument.Styles

Here's where things start to get interesting. That line tells the macro to cycle through each style (represented by aStyle) in all of the styles in the active document (the document in which your cursor is currently sitting).

aStyle.Font.Name = "Adobe Garamond"

And that line tells Word to set the font for the style currently being represented by aStyle to be Adobe Garamond.

Next

The “Next” line tells Word to go to the next style in the document.

When you run the macro, it will cycle through each style in the document (For Each…) and set Adobe Garamond as the font used in that style.

But what if you want to change the font only in heading styles (Heading 1, Heading 2, and so on)? Try this:

Dim aStyle As Style
For Each aStyle In ActiveDocument.Styles
If InStr(aStyle.NameLocal, "Heading") Then aStyle.Font.Name = "Adobe Garamond"
Next
End Sub

Here's the line of interest:

If InStr(aStyle.NameLocal, "Heading") Then aStyle.Font.Name = "Adobe Garamond"

That line uses a macro command we haven't seen before, InStr, which checks for specific text in a larger string of text. In this case, it checks to see if the text “Heading” appears in the name of the style (for example, “Heading 4”). If it does, then the macro sets the font for the Heading style as Adobe Garamond.

Armed with that little beauty, you can pull off all kinds of formatting marvels. Here are just a few of the options available:

If InStr(aStyle.NameLocal, "Heading") Then aStyle.Font.Bold = True

If InStr(aStyle.NameLocal, "Heading") Then aStyle.ParagraphFormat.Alignment = wdAlignParagraphCenter

If InStr(aStyle.NameLocal, "Heading") Then aStyle.NoSpaceBetweenParagraphsOfSameStyle = True

You can even specify the exact name of the style (rather than using InStr):

If aStyle.NameLocal = "Normal" Then aStyle.ParagraphFormat.Alignment = wdAlignParagraphJustify

If aStyle.NameLocal = "Heading 3" Then aStyle.Font.Italic = True

All of Word’s formatting options are at your disposal.

So yes, if you’re formatting a Word document, you should always use styles. But if you need to modify styles en masse, now you know how.

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.

________

How to Add Macro to Word & to the QAT

Here’s how to put this macro (or any other) 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.”
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  4. Type a name for the macro in the “Macro name” box — probably the name used after the first “Sub.” For this macro, that’s “______________.”
  5. Click the “Create” button.
  6. Delete the “Sub [macro name]” and “End Sub” lines that Word created in the macro window. The macro window should now be completely empty (unless you already have other macros in there).
  7. Paste the macro text at the current insertion point.
  8. Click “File,” then “Close and Return to Microsoft Word.”

To actually use the macro:

  1. Place your cursor ___________________.
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  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.)

Here’s how to put the macro on Word’s QAT (Quick Access Toolbar):

  1. Locate the QAT (it’s probably on the top left of your screen either above or below Word’s Ribbon interface).
  2. Right-click the QAT.
  3. Click “Customize Quick Access Toolbar.”
  4. Under “Choose commands from:” click the dropdown list and select “Macros.”
  5. Find and select your macro in the list on the left.
  6. Click the “Add” button to add it to the QAT.
  7. Click the “OK” button to finish.

Lyonizing Word: Let’s Go Spelunking

 Let’s Go Spelunking

by Jack Lyon

Spelunking is the recreational pastime of exploring caves. It’s a dark and dangerous hobby, an extreme sport for those who are confident in their ability to climb, navigate, and even swim (there’s usually water down there).

I try to avoid such hazards, but I’m not afraid to explore some of the deeper reaches of a computer program — Microsoft Word, for example. That’s one reason I know quite a bit about that particular program. Some of my friends, however, seem terrified of making a “mistake” on the computer. They want a concrete series of steps to follow in everything they do. “How can I make a word bold?” they ask. I reply:

  1. Double-click the word to select it.
  2. Click the “Bold” icon on the Ribbon.

Then they say, “Oh, that’s wonderful! Let me write that down for next time.”

There’s nothing inherently wrong with learning to use a computer in that way, and those who are comfortable with that should keep a big Microsoft Word reference book close at hand. These are probably the same people who would enjoy taking a guided tour of Timpanogos Cave, which is about an hour away from where I live.

But that’s a far cry from spelunking, and I doubt that any of the people on the tour discover something new.

So what kind of a person are you? Do you like someone to hold your hand along the well-marked trail? Or would you rather descend into the dark depths of the cavern with only a flashlight as your guide? Either way is fine, but sometimes it’s nice to get off the beaten path; you never know what you might find. As Henry David Thoreau once said, “Nature abhors a vacuum, and if I can only walk with sufficient carelessness I am sure to be filled.”

Want to learn something new about Word? Try exploring Word’s features that aren’t on any menu, the caverns that aren’t on the map. Here’s how:

  1. Press ALT+F8 to open the Macros dialog.
  2. Click the dropdown list next to “Macros in.”
  3. Select “Word Commands.”

Now, in the window under “Macro name,” you’ll see all of the commands available in Microsoft Word, whether they’re on the Ribbon or not. If you click one, you’ll see a description of its function under “Description,” at the bottom of the dialog. These descriptions are minimal at best, but along with the name of the command, they’ll give you some idea of what the command does. You can also click the “Run” button to run the command, which may give you even more insight. (Be sure to do this only with a junk document; you don’t want mess up an actual project.)

Let’s take a look. Don’t be afraid; I’ll be right behind you all the way.

So we’re scrolling through the list of Word commands in Word 2013, and what do we see? “CharacterRemoveStyle,” which, according to its description, “Clears character style from selection.” What?!? Does this mean it’s possible to remove a character style without affecting text-level formatting (such as italic)? If so, I sure didn’t know about it. Let’s find out. We type a junk sentence into a junk document:

This is a test to see what will happen.

We apply italic formatting to “test” and the character style “Emphasis” character style to “see”:

This is a test to see what will happen.

The formatting of those two words looks the same, but the formatting is not the same. Now let’s see if the “CharacterRemoveStyle” command works. We select the sentence, press ALT+F8, scroll down to “CharacterRemoveStyle,” and run it. Look at that! Our test sentence becomes:

This is a test to see what will happen.

The character style is gone, but the text-level formatting is still there. Neat!

Okay, one more, and then we’ll go back up to the surface. Down, down, down, scrolling, scrolling, scrolling. What’s this? “RestoreCharacterStyle.” I’ve never noticed that command before. The description says “Restores character style and removes direct formatting.” Could this be the inverse of the command we just finished exploring? Again we type our junk sentence and apply the same formatting as before:

This is a test to see what will happen.

Then we select the sentence and run the “RestoreCharacterStyle” command. Yes! The sentence now looks like this:

This is a test to see what will happen.

The text-level formatting is gone, but the character style remains!

But why does Microsoft say that this command restores a character style? If we remove the character style from our sentence and then run the command, does the character style come back? A quick experiment shows us that no, it doesn’t. Then why the odd name? I suspect that under the hood, Word is removing all character-level formatting but then restoring any formatting applied with a character style. It’s the equivalent of (1) identifying the character style, (2) pressing CTRL+SPACEBAR (to remove character-level formatting), and then (3) reapplying the character style — which means that the command was named from the programmer’s perspective rather than the user’s perspective. There’s a lot of stuff like that down here in the dark, and it’s part of what makes exploring so interesting.

Back up in the daylight, we assess our adventure, which I’d have to say has been a success. We’ve discovered two commands we didn’t know about before. Could they be useful in our actual editing work? Yes, indeed!

Personally, I enjoy crawling around down there in the bowels of Microsoft Word. Yes, it’s dark and it’s dirty, and sometimes I find something nasty under a rock. But I also make lots of interesting discoveries, and I nearly always learn something new.

How about you? Ready to go spelunking on your own? Have fun, and don’t forget your flashlight!

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.

Lyonizing Word: Formatting with Macros

Formatting with Macros

by Jack Lyon

Most users of Microsoft Word format text by selecting a paragraph and then applying a font. More advanced users apply a style. Why? Because then if they need to change the formatting of, say, level-2 headings, they can simply modify the style rather than tediously selecting each heading and applying a different font. (If you’re reading this, you’re probably one of those advanced users.) But there is a way to handle formatting that is even more powerful.

Suppose that you’ve dutifully applied styles to the various parts of a document, but then your client asks you to change the font—everywhere in the document—from Times New Roman to Adobe Garamond. You could manually modify each style, but if there are dozens of styles in use, there is a better way. That way is a macro, like this one:

Sub SetFontInAllStyles()
Dim aStyle As Style
For Each aStyle In ActiveDocument.Styles

aStyle.Font.Name = "Adobe Garamond"

Next
End Sub

Well, that was easy. Let's look at each line of the macro (excluding the first and last lines, which simply define the beginning and end of the macro).

Dim aStyle As Style

That line dimensions (defines) a variable, aStyle, as a style. (As with all variables, I just made up the name “aStyle.”) At one point as the macro runs, aStyle might represent the style Heading 1. At another point it might represent Heading 3. But it will always represent a style.

For Each aStyle In ActiveDocument.Styles

Here's where things get interesting. That line tells the macro to cycle through each style (represented by aStyle) in all of the styles in the active document (the document in which your cursor is currently sitting).

aStyle.Font.Name = "Adobe Garamond"

That line tells Word to set the font for the style currently being represented by aStyle to be Adobe Garamond.

Next

That line tells Word to go to the next style in the document.

When you run the macro, it will cycle through each style in the document (For Each…Next) and set Adobe Garamond as the font used in that style.

But what if you want to change the font only in heading styles (Heading 1, Heading 2, and so on)? Try this:

Dim aStyle As Style
For Each aStyle In ActiveDocument.Styles

If InStr(aStyle.NameLocal, "Heading") Then aStyle.Font.Name = "Adobe Garamond"

Next
End Sub

Here's the line of interest:

If InStr(aStyle.NameLocal, "Heading") Then aStyle.Font.Name = "Adobe Garamond"

The line uses a macro command we haven't seen before, InStr, which checks to see if a specific string of text is used somewhere. In this case, it checks to see if the text “Heading” appears in the name (NameLocal) of the style currently represented by aStyle. If it does, then the name of the font used in that style is set to Adobe Garamond.

You could even specify the exact name of the style to be changed:

If aStyle.NameLocal = "Block Quote" Then aStyle.Font.Name = "Adobe Garamond"

And that should give you an idea of how to modify a bunch of styles, all at once (between “For Each” and “Next”), to use various fonts:

If aStyle.NameLocal = "Poem" Then aStyle.Font.Name = "Arial"

If aStyle.NameLocal = "Author" Then aStyle.Font.Name = "Apple Boy"

If aStyle.NameLocal = "Subtitle" Then aStyle.Font.Name = "Constantia"

Much more can be done to automate the formatting of text using macros. I hope this brief article will get you started.

How to Add Macro to Word & to the QAT

Here’s how to put this macro (or any other) 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.”
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  4. Type a name for the macro in the “Macro name” box — probably the name used after the first “Sub.” For this macro, that’s “CleanCellEndSpaces.”
  5. Click the “Create” button.
  6. Delete the “Sub [macro name]” and “End Sub” lines that Word created in the macro window. The macro window should now be completely empty (unless you already have other macros in there).
  7. Paste the macro text at the current insertion point.
  8. Click “File,” then “Close and Return to Microsoft Word.”

To actually use the macro:

  1. Place your cursor at the beginning of the document.
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  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.)

Here’s how to put the macro on Word’s QAT (Quick Access Toolbar):

  1. Locate the QAT (it’s probably on the top left of your screen either above or below Word’s Ribbon interface).
  2. Right-click the QAT.
  3. Click “Customize Quick Access Toolbar.”
  4. Under “Choose commands from:” click the dropdown list and select “Macros.”
  5. Find and select your macro in the list on the left.
  6. Click the “Add” button to add it to the QAT.
  7. Click the “OK” button to finish.

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.