
Tips.Net > WordTips Home > Editing > Adding Hyphens to Phrases
Summary: It is often necessary to add hyphens (dashes) between the words in a phrase. If you need to perform this editing task often, you might appreciate the macro in this tip. Assign it to a shortcut key, and you can hyphenate phrases very quickly. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)
Evelyn is looking for a way to add hyphens to phrases that were originally typed in without the phrases. For instance, if the phrase "we are having a bigger and better than ever sale this week" is typed in, Evelyn may want it to instead read "we are having a bigger-and-better-than-ever sale this week." The hyphens that denote the phrase need to replace all the spaces that were previously between the words in the phrase.
The quickest solution is to simply select the words in the phrase (bigger and better than ever) and use Find and Replace to replace all the spaces with dashes. Of course, this involves several steps, and if you face this scenario quite often, you should consider a macro to do the actual replacing. The following macro, for instance, will automate the task:
Sub MakePhrase()
If Selection.Type <> wdSelectionIP Then
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " "
.Replacement.Text = "-"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End If
End Sub
The macro first checks to make sure that a selection has been made. If so, then all the spaces in the selection are replaced with dashes. To make the macro handier, simply assign it to a shortcut key. Then, when you need to hyphenate a phrase, simply select the words and press the shortcut key.
Tip #343 applies to Microsoft Word versions: 97 2000 2002 2003
Find and Replace Almost Anything! Learn the ins and outs of the powerful search engines available in Word. Learn to search for and replace text, formatting, graphics, and special characters the easy way with WordTips: Find and Replace.
Discover how to use Word's mail merge tool to create your own custom documents in just minutes. Great e-book answers all your questions. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Pet Tips
Word2007 Tips
WordTips