View Single Post
 
Old 05-28-2022, 08:37 PM
stky stky is offline Windows 10 Office 2013
Advanced Beginner
 
Join Date: Apr 2021
Posts: 30
stky is on a distinguished road
Default can we do or not like this method but I fail

Code:
Sub EmDash()
Dim rngStory As Range
    For Each rngStory In ActiveDocument.StoryRanges
Dim MyList() As String
Dim i As Long
Options.DefaultHighlightColorIndex = wdTurquoise
MyList = Split("—,[ ]{1,}—[ ]{1,}")
For i = 0 To UBound(MyList())
    Set r = ActiveDocument.Range
        With rngStory.Find
            .Text = MyList(i)
            .Replacement.Text = "^32—^32"
            .MatchWildcards = True
            .MatchCase = True
            .Replacement.Highlight = wdTurquoise
            .Execute Replace:=wdReplaceAll
    End With
    Next
Next
End Sub

Last edited by macropod; 05-29-2022 at 06:57 AM. Reason: Added code tags
Reply With Quote