PDA

View Full Version : [SOLVED:] Not replacing kindly help where i missed



karey
11-16-2022, 10:28 AM
Sub Symbol()Options.DefaultHighlightColorIndex = wdBrightGreen
Application.ScreenUpdating = False
Dim rngStory As Range, i As Long
Dim StrOld As String, StrNew As String
StrOld = "ChrW(-3988)|ChrW(-4030)"
StrNew = "ChrW(955)|ChrW(914)"
For Each rngStory In ActiveDocument.StoryRanges
With rngStory
Select Case .StoryType
Case wdMainTextStory, wdEndnotesStory, wdFootnotesStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
.Forward = True
.Wrap = wdFindStop
.Format = False
For i = 0 To UBound(Split(StrOld, "|"))
.Text = Split(StrOld, "|")(i)
.Replacement.Text = Split(StrNew, "|")(i)
.Replacement.Font.Name = "Times New Roman"
.Replacement.Highlight = True
.Execute Replace:=wdReplaceAll
Next
End With
End Select
End With
Next rngStory
Application.ScreenUpdating = True
End Sub

gmayor
11-17-2022, 10:25 PM
The following will work

Sub Symbol()
Options.DefaultHighlightColorIndex = wdBrightGreen
Application.ScreenUpdating = False
Dim rngStory As Range, i As Long
Dim vOld As Variant, vNew As Variant
vOld = Array(ChrW(-3988), ChrW(-4030))
vNew = Array(ChrW(955), ChrW(914))
For Each rngStory In ActiveDocument.StoryRanges
With rngStory
Select Case .StoryType
Case wdMainTextStory, wdEndnotesStory, wdFootnotesStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
.Forward = True
.Wrap = wdFindStop
.Format = False
For i = 0 To UBound(vOld)
.Text = vOld(i)
.Replacement.Text = vNew(i)
.Replacement.Font.Name = "Times New Roman"
.Replacement.Highlight = True
.Execute Replace:=wdReplaceAll
Next
End With
End Select
End With
Next rngStory
Application.ScreenUpdating = True
End Sub