S
Staroslav
Hello!
I have a Find/Replace (FR) procedure that for some unknown to me reason
flips around the first letter of a word with the left quotation mark, so
"This" becomes T"his". Can any one help explain why that happens and offer a
working solution?
Here is the code I am using:
Call FR("([^0034^0171^0148])([Ð-Ñ‘ÐA-Za-z0-9])", "^0147\2", True)
Sub FR(FT As String, RT As String, _
Optional bWild As Boolean = False, _
Optional bFormat As Boolean = False)
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Text = ""
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Text = ""
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = FT
.Replacement.Text = RT
.Forward = True
.Wrap = wdFindStop
.Format = bFormat
If bFormat = True Then
.Replacement.Font.Bold = False
.Replacement.Font.Italic = False
End If
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = bWild
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute
'Keep going until nothing found
.Execute Replace:=wdReplaceAll
Loop
'Free up some memory
ActiveDocument.UndoClear
End With
Selection.Find.ClearFormatting
Selection.Find.Text = ""
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Text = ""
Selection.Find.MatchWildcards = False
End Sub
I have a Find/Replace (FR) procedure that for some unknown to me reason
flips around the first letter of a word with the left quotation mark, so
"This" becomes T"his". Can any one help explain why that happens and offer a
working solution?
Here is the code I am using:
Call FR("([^0034^0171^0148])([Ð-Ñ‘ÐA-Za-z0-9])", "^0147\2", True)
Sub FR(FT As String, RT As String, _
Optional bWild As Boolean = False, _
Optional bFormat As Boolean = False)
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Text = ""
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Text = ""
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = FT
.Replacement.Text = RT
.Forward = True
.Wrap = wdFindStop
.Format = bFormat
If bFormat = True Then
.Replacement.Font.Bold = False
.Replacement.Font.Italic = False
End If
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = bWild
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute
'Keep going until nothing found
.Execute Replace:=wdReplaceAll
Loop
'Free up some memory
ActiveDocument.UndoClear
End With
Selection.Find.ClearFormatting
Selection.Find.Text = ""
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Text = ""
Selection.Find.MatchWildcards = False
End Sub