Word: Replace text in quotes with bold textMay 14, 2008
A word of warning about this procedure: If your document contains programming code that uses quote marks, you shouldn’t use this method without trying it on a copy first.
Occasionally I’ve received a Word document that has all the field names enclosed in quotation marks. My preferred typographic style for field names is bold, no quotes. Which means that I have a lot of find/replace actions to do in a long document. I can’t write or record a macro as I might replace legitimate quotation marks, especially single quotes used for apostrophes.
I knew that Word had some powerful wildcard/regular expression functions in its Find/Replace function, but they are very hidden and they’re not something I’ve needed to learn. However, when faced with a 50 page document (small compared to others I’ve received) peppered with field names enclosed in quote marks, it was time to bite the bullet!
Word’s Help, particularly the Help that goes out to the Microsoft website (I hate that!), is difficult to navigate unless you know what you’re looking for, so I turned to one of my favourite websites: the Word MVPs site (http://word.mvps.org). I found what I was looking for here, but there was a critical step missing.
So here are my steps for removing single quotes surrounding a field name and formatting the enclosed text with bold. I’ve adapted these steps from those provided on the MVPs site:
- Open the AutoCorrect Options:
* Word 2003: From the menu, select Tools > AutoCorrect Options.
* Word 2007: Click the large Microsoft button in the top left, click Word Options, click Proofing, then click the AutoCorrect Options button in the AutoCorrect options section.
- Go to the AutoFormat As You Type tab.
- In the Replace as you type section (at the top), select the “Straight” quotes with “smart quotes” check box, then click OK. This is essential—you can change it back later if you always keep it turned off, but this check box must be on when you are doing the Find/Replace.
- Open the Find and Replace window (press Ctrl+H, or select Edit > Replace from the menu).
- Type ‘ in the Find what field.
- Type ‘ in the Replace with field.
- Click Replace All. Yes, you’re replacing the quote mark with itself. What this does is replace all the straight quote marks throughout your document with curly ones (smart quotes), including your apostrophes. You can always switch the apostrophes back to straight quotes later by repeating the steps above (don’t forget to clear the check box at step 3).
- Put your cursor in the Find what field, delete the existing quote mark, then type (‘)(*)(’). CRITICAL: The opening and closing quote marks MUST be smart quote marks, so you’ll have to copy/paste them from the document into the Find What field to make sure you have the correct ones. Don’t accidentally copy any preceding or trailing spaces.
- Select the Use wildcards check box. If you can’t see this check box, click the More button.
- Go to the Replace with field, delete the quote mark, and type \2. (No, I don’t know what \2 means either, and it must be REALLY hidden in the Microsoft Help as I can’t find it there either, and a Google search brings up too many spurious results.)
- Click the Format button, then select Font.
- Select Bold, then click OK.
- Back on the Find and Replace window, click Replace All. Everything that was enclosed in single quotes is now bold and the quotes have been removed.
- If you really like using straight quotes, don’t forget to turn them back on!
[steps updated to incorporate Word 2007, 21 August 2008]