Copying and Pasting Styles

If you frequently use styles (which you should) to format your documents or specify text levels for typesetting, you're probably aware that you can press CTRL + SHIFT + S to activate the style list. (Then you can scroll through the list to get the style you need.)

You may not be aware, however, that you can easily copy and paste styles (both paragraph and character styles), just as you can copy and paste text. If you've never done this before, it will make you smile. Here's the procedure:

1. Put your cursor on some text formatted with the style you want to copy (Heading 1, for example).

2. Press CTRL + SHIFT + C (just like the keyboard shortcut for copying text, but with the SHIFT key added).

3. Move your cursor to (or select) the text you want to format with the style you just copied.

4. Press CTRL + SHIFT + V (just like the keyboard shortcut for pasting text, but with the SHIFT key added).

The text will be formatted with the style you copied.

_________________________________________

READERS WRITE

Jeff Ross sent the following macro to clean up text copied into Word from an email message. Thanks, Jeff!


Sub CleanMyMessage()
' CleanMyMessage Macro
' Macro recorded 3/11/02 by Jeff Ross
'Remove angle brackets with spaces
With Selection.Find
.Text = "> "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Remove other angle brackets
With Selection.Find
.Text = ">"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Remove spaces before paragraph breaks
With Selection.Find
.Text = " ^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Mark true paragraph breaks with unique character
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "?"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Replace other (false) paragraph breaks with spaces
With Selection.Find
.Text = "^p"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Replace unique character with paragraph break
With Selection.Find
.Text = "?"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Turn double hyphens to em dashes
With Selection.Find
.Text = "--"
.Replacement.Text = "^+"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Turn straight single quotation marks into curly ones
'Note: For this to work, the AutoFormat option
'to replace straight quotes with curly quotes must be on
'(Click Tools > AutoCorrect > AutoFormat As You Type >
'Replace as you type > straight quotes with smart quotes)
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "'"
.Replacement.Text = "'"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Turn straight double quotation marks into curly ones
'Note: For this to work, the AutoFormat option
'to replace straight quotes with curly quotes must be on
'(Click Tools > AutoCorrect > AutoFormat As You Type >
'Replace as you type > straight quotes with smart quotes)
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = """"
.Replacement.Text = """"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

If you don't know how to use macros like this one, you can learn how here.

_________________________________________

RESOURCES

Dan A. Wilson, expert online editor and proprietor of The Editor's Desktop, provides several useful resources for editors, including:

* a basic FTP tutorial (if you need to transmit electronic manuscripts to clients)

* suggestions for choosing anti-virus software

* a discussion of freelancers' rates

* a recommended list of reference works (printed and electronic) for editors

* a low-tech guide to Wintel computer maintenance

* information about installing a firewall on your computer

You can read Dan's articles here:

http://www.editorsdesktop.com/articles.html

And you can check out his editing services here:

http://www.editorsdesktop.com/index.html

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

Removing Directly Applied Formatting

Last week I discussed the evils of directly applied formatting but didn't explain how to get rid of it. I know what you're going to say: "Just press CTRL + A to select all and then press CTRL + SPACE." That will remove it, all right. The problem is, it will also remove italics, bold, and other formatting that you want to *keep.*

For example, let's say you're editing a scholarly tome with acres and acres of footnotes. Nearly every one of those notes is going to cite a book or journal of some kind--with the title of each publication in italics (represented here with asterisks), like this:

39. G. B. Harrison, *The Profession of English* (New York: Anchor Books, 1967), p. 166.

But if you do the CTRL + SPACE thing, you're going to get this:

39. G. B. Harrison, The Profession of English (New York: Anchor Books, 1967), p. 166.

So what are you going to do? Go back and italicize everything by hand?

There *is* a better way. In general terms, here's the procedure:

1. Identify each kind of directly applied formatting you want to keep--italics, strikethrough, whatever. Maybe make a list.

2. Find and replace each kind of formatting with a unique code. For example, you might use |I| to indicate italic and |B| to indicate bold. (More on this in a minute.)

3. Press CTRL + A to select all and CTRL + SPACE to remove all directly applied formatting.

4. Find and replace your codes with the appropriate formatting.

Now let's get specific and say you're trying to preserve italics. Here's what you'd do:

1. Click Edit > Replace to open Word's Find and Replace dialog.

2. Leave the "Find What" box empty but press CTRL + I to specify italic formatting. The box will now say "Font: Italic" underneath.

3. In the "Replace With" box, enter this:

|I|^&|I|

That code in the middle, ^&, is the "Find What Text" wildcard, which tells Word to use whatever it *finds* (in this case, any italicized text) as the *replacement* between your italic codes. You can learn more about the "Find What Text" wildcard here:

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

4. Click the "Replace All" button. All of your italicized text will now be marked with codes, like this:

39. G. B. Harrison, |I|The Profession of English|I| (New York: Anchor Books, 1967), p. 166.

(If you wanted to preserve other kinds of formatting, such as bold, you'd repeat steps 1 through 4 here, with different codes for each kind of formatting.)

5. Press CTRL + A to select all and CTRL + SPACE to remove directly applied formatting. Woo-hoo! Pretty scary, no? (You did keep a backup, right?)

6. Click Edit > Replace to open Word's Find and Replace dialog.

7. In the "Find What" box, enter the formatting codes and the * wildcard (in parentheses) to represent any text between the codes, like this:

|I|(*)|I|

8. Click the "No Formatting" button. The "Font: Italic" notation will go away.

9. In the "Replace With" box, enter this:

1

That code tells Word to use any text it *finds* between italic codes as the *replacement* for the codes and the text between them. Clear as mud? You'll understand when you try it. You can learn more about the "Find What Expression" wildcard here:

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

10. With your cursor still in the "Replace With" box, press CTRL + I to specify italic formatting. The box will now say "Font: Italic" underneath.

11. Put a checkmark in the "Use wildcards" (or "Use pattern matching") box. You may need to click the "More" button before this is available.

12. Click the "Replace All" button. All of your italicized text will be restored to its former glory--and all of the directly applied formatting that you *didn't* want (such as 12-point Baskerville) will be gone!

If you need to do this kind of thing a lot, you can record the procedure in a macro that you can use over and over again. 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

Or, if you'd like a macro that will clean up directly applied formatting (but preserve character formatting such as italic) in a whole folder full of documents at the same time, you might try our FileCleaner program, which you can learn more about here:

http://www.editorium.com/14845.htm

_________________________________________

READERS WRITE

Last week Rich Shattenberg asked if it's possible to use wildcards in a custom spell-check dictionary. You can read his question here:

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

This week, expert Word-whacker Steve Hudson sent the definitive reply:

"No wildcards in dic entries. Badda badda boom."

Many thanks to Steve. It wasn't really the answer we wanted, but it's always good to know the facts.

_________________________________________

RESOURCES

The Office Letter

The Office Letter is a weekly email newsletter that provides a plethora of tips, tricks, tools, and techniques for using Microsoft Office. It's a *nice* publication, as you can see here:

http://www.officeletter.com/current.html

And hey, the current edition includes our NameSwapper macro!

The standard edition of The Office Letter is free. The premium edition includes access to all back issues, a fast search engine, and no advertising, all for just $12 a year. You can sign up for either edition here:

http://www.officeletter.com/sub/subscribe.html

Why not check it out?

Frustrating Formatting

If you use Microsoft Word, I guarantee you've been frustrated by its formatting, especially if you edit someone else's documents. For example, you modify the Heading 1 style to use Palatino rather than Arial--but Arial it remains. What's going on here?

Consider my living room wall, which I daringly painted red. Then, coming to my senses, I painted it grayish green. But wait . . . What *was* I thinking? Finally, I covered it with an almond color that looked okay.

Microsoft Word's formatting works pretty much the same way. It's done in layers, like paint on a wall.

The underlying layer is the formatting of paragraph styles. For example, if you apply the Heading 1 paragraph style using Word's defaults, your text will be formatted in 16-point Arial bold. If you attach a new template to your document (and check the box labeled "Automatically Update Document Styles"), the formatting of Heading 1 will change to whatever is specified in the new template (18-point Baskerville italic, for example). Note that this doesn't change the style formatting in your Normal template. It just paints over that formatting *in your document.* And if you "detach" the new template, the formatting won't change back. Once the paint is on there, it's on there. Of course, you can always attach a *different* template or modify the styles in the document itself if you want to change the formatting yet again.

The next layer up is the formatting of character styles. You can use character styles to format text selections smaller than a paragraph. For example, you might use a character style called Book Title to format book titles in Times Roman italic. Like paragraph styles, character styles can be changed by attaching a different template or modifying the styles in the document itself.

Finally, on the topmost layer, your document could have directly applied formatting. That's what you get if you simply select some text and apply, say, 18-point Baskerville italic without using a style. In all but the simplest documents, this kind of formatting is of the devil. Why? Because you can't change it simply by modifying the underlying style--and that means you have no way to control it (or even identify it) *throughout* the document. So, if you modify the Heading 1 style to use Palatino rather than Arial--well, Arial it remains.

How can you avoid this problem in your documents?

1. Don't use directly applied formatting.

2. Use character styles to format text selections smaller than a paragraph.

3. Use paragraph styles to format everything else.

4. To change your formatting, modify the *style* that produces it.

But what if you're working on someone else's documents? You'll probably want to remove all that directly applied formatting and use styles instead. But that's a topic for another day.

_________________________________________

READERS WRITE

Rich Shattenberg (shatts@world.cbi.org) wrote:

"I don't have a hint but I have a question and a problem. I live in the country of Madagascar. There is no Word spell checker for the Malagasy language, or at least I have not yet been able to find one. I have made a custom dictionary with about 7,000 words to do spell checks in Malagasy. However, here is the challenge.

"The word 'mandeha' means 'to go' (present tense), 'Nandeha' is past tense, and 'handeha' is future tense. For the custom dictionary, I have to enter all three words. I have not yet been able to find wildcard symbols to use in the custom dictionary.

"For example, is there a way of telling the custom dictionary to accept the word 'andeha' if there is either a 'm' or 'n' or 'h' in front of the word. This would mean I only have to make one entry for the three words."

I'm researching this, but do you, gentle reader, have an answer (or other questions, hints, or comments you'd like to share)? If so, please send me an email message here: mailto:hints [at symbol] editorium.com

_________________________________________

RESOURCES

If you're not familiar with the Tech-whirl Web site (TECHWR-L), you should be. It presents some of the finest information on technical writing and editing on the planet. You may also be interested in subscribing to the TECHWR-L discussion list, which is one *active* list. Why not check it out?

http://www.raycomm.com/techwhirl/index.php3