Back once again. I can't this macro to run. It's to delete any spaces on either side of an em dash in a document. Seems simple enough. I started with a recorded one, then made alterations as I saw it wasn't working. It chokes on the line in red; no clue why, since I don't know VBA.
Thanks.
Code:
Sub Ems()
'
' Ems Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "(Chr(32)^+)"
.Replacement.Text = "^+"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "(^+Chr(32))"
.Replacement.Text = "^+"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.Close
Application.Quit
End Sub