Another issue. I'm using wildcards in the script but it's not working, see below. I've added MatchWildcards:=True, _ runs without errors but replaces with actual characters.
Sub Punctuation()
Dim vFindText As Variant
Dim vReplaceText As Variant
Dim oRng As Range
Dim i As Long
vFindText = Array(":^tSO ", ". SO ", "? SO ", "WORKERS COMPENSATION", "WORKERS COMP", "WORKER'S COMPENSATION", "WORKER'S COMP")
vReplaceText = Array(":^tSO, ", ". SO, ", "? SO, ", "WORKERS' COMPENSATION", "WORKERS' COMP", "WORKERS' COMPENSATION", "WORKERS' COMP")
For i = 0 To UBound(vFindText)
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(findText:=vFindText(i), _
MatchWholeWord:=True, _
Forward:=True, _
MatchWildcards:=True, _
Wrap:=wdFindStop) = True
oRng.Text = vReplaceText(i)
oRng.Collapse wdCollapseEnd
Loop
End With
Next
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
|