smallxyz
07-18-2016, 10:27 PM
Below is my attempted code.
However, it colors the texts of whole documents instead of the selected ones.
How should I amend it to become effective?
Sub Test
Call mCrRp("the", "wdColorRed", False)
End Sub
Sub mCrRp(ByVal f As String, _
ByVal Cr As String, _
ByVal bool As Boolean _)
Application.ScreenUpdating = False
'--------------------------------------
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Font.Color = Cr
.Replacement.Highlight = bool
.Text = f
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute replace:=wdReplaceAll
End With
'--------------------------------------
End Sub
Thanks in advance.
However, it colors the texts of whole documents instead of the selected ones.
How should I amend it to become effective?
Sub Test
Call mCrRp("the", "wdColorRed", False)
End Sub
Sub mCrRp(ByVal f As String, _
ByVal Cr As String, _
ByVal bool As Boolean _)
Application.ScreenUpdating = False
'--------------------------------------
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Font.Color = Cr
.Replacement.Highlight = bool
.Text = f
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute replace:=wdReplaceAll
End With
'--------------------------------------
End Sub
Thanks in advance.