I have a procedure that finds a word in word documents. It finds the word, and changes the font size, but the found word remains black. Any ideas why, thanks
'Create an instance of MS Word
Set WD = CreateObject(Class:="Word.Application")
'WD.Visible = True
'
' 'Open the Document
WD.Documents.Open Filename:=LWordDoc, ReadOnly:=True
Me.List152.SetFocus
Me.List152.ListIndex = 0
For TY = 0 To Me.List152.ListCount - 1
Me.List152.ListIndex = TY
With WD.Selection.Find
.ClearFormatting
.Text = "When"
.Replacement.ClearFormatting
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do While WD.Selection.Find.Execute
ccny = ccny + 1
If WD.Selection.Find.Found Then
With WD.Selection.Font
.Color = wdColorRed
.Name = "Arial"
.Size = 18
.Bold = True
.Italic = True
.Underline = wdUnderlineAll 'None
.UnderlineColor = wdColorAutomatic
.Strikethrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = True
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
End If
Loop
Next TY
DoEvents
WD.ActiveDocument.Saved = True
WD.Visible = True
Set rst = Nothing
Set db = Nothing
Me.Command153.Enabled = True
End Sub
'Create an instance of MS Word
Set WD = CreateObject(Class:="Word.Application")
'WD.Visible = True
'
' 'Open the Document
WD.Documents.Open Filename:=LWordDoc, ReadOnly:=True
Me.List152.SetFocus
Me.List152.ListIndex = 0
For TY = 0 To Me.List152.ListCount - 1
Me.List152.ListIndex = TY
With WD.Selection.Find
.ClearFormatting
.Text = "When"
.Replacement.ClearFormatting
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do While WD.Selection.Find.Execute
ccny = ccny + 1
If WD.Selection.Find.Found Then
With WD.Selection.Font
.Color = wdColorRed
.Name = "Arial"
.Size = 18
.Bold = True
.Italic = True
.Underline = wdUnderlineAll 'None
.UnderlineColor = wdColorAutomatic
.Strikethrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = True
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
End If
Loop
Next TY
DoEvents
WD.ActiveDocument.Saved = True
WD.Visible = True
Set rst = Nothing
Set db = Nothing
Me.Command153.Enabled = True
End Sub