Mark Ward’s Miracle Word-Macro Wonder

The MWMWMW is now available for free—for a limited time only (till the Internet dies, I guess).

Use this macro to 1) sharpen up any Word document and 2) impress nerdy people with proper use of a) en dashes and b) em dashes.

This macro replaces — with —. It also removes spaces surrounding em dashes, makes all hyphens between numbers into en dashes, turns all quotation marks and apostrophes into curvy quotes (as long as you have “Smart-quotes” turned on), replaces all double spaces with single spaces, and generally makes me feel good about the typographical state of my documents.

Just open a blank Word document, hit Alt+F8, click “Edit,” and paste the text below into your macros list at the bottom. Save and close Word, agreeing to save changes to Normal.dot. You can even assign a button or keyboard shortcut to this macro.

Sub MWMWMW()
' Mark Ward's Miracle Word-Macro Wonder
' Macro recorded Thursday, September 11, 2003 by Mark L Ward Jr
   Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
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
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
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
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
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
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
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
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([0-9])-([0-9])"
.Replacement.Text = "\1–\2"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Author: Mark Ward

PhD in NT; theological writer for Faithlife; former high school Bible textbook author for BJU Press; husband; father; ultimate frisbee player; member of the body of Christ.

3 thoughts on “Mark Ward’s Miracle Word-Macro Wonder”

  1. I don’t know about Macs, but I still do VBA in Word 2007 (on Windows, mind you). In the Word Options dialog you turn on the Developer toolbar and then you can get into all the lovely internals of Office 07! (Or just type Alt+F11)

    In order to save macros in a 2007 Word doc, the file extension changes from*.docx to *.docm.

    Nice macro, BTW… I think a lot of those settings in the With Selection.Find blocks could be trimmed out though. Word always worries about too many details with recorded macros. I’ll let you know if I can achieve the same results with trimmed code.

Leave a Reply