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: 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.