WordTips (Menu Interface)
Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.
With more than 35 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company.
Learn more about Allen...
WordTips FAQ
Ask a Word Question
Make a Comment
Free Business Forms
Free Calendars
It is not uncommon to use repeating design elements in a document. For instance, you may want all occurrences of a particular word to appear in bold italics, at a certain point size. While you can certainly do the formatting by hand, it is much more efficient to allow a macro to do the work for you. By handling the formatting in this way, you don't need to worry about remembering how the word should appear. This macro, FormatWords, is an example of such a macro.
Sub FormatWords()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Warning!"
.Replacement.Text = ""
.Replacement.Font.Bold = True
.Replacement.Font.Italic = True
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
When you run this macro, it searches for all occurrences of the word Warning (followed by an exclamation point) and changes the formatting on it so the word is bold and italics.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1762) applies to Microsoft Word versions: 97 2000 2002 2003
You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Using a Macro to Change the Formatting of All Instances of a Word.
Related Tips:
Find and Replace Almost Anything! An invaluable resource for learning how to harness the full power of Word's search and replace capabilities. You'll discover everything you need in order to master all the intricacies of finding and replacing elements of your document, including the super-powerful "wildcard searches" available in Word. Check out WordTips: Find and Replace today!