selection.find.font.color NOT equal to red not working

F

frogman

Why doesn't the <> or the =not(wdColorRed) work

'find and replace the the hidden text with double lined text
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.Font.Color <> wdColorRed
.Font.Italic = False
.Font.Hidden = True
.Replacement.Font.Hidden = False
.Replacement.Font.DoubleStrikeThrough = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
 
T

Tony Jollans

Word's Find just doesn't have that capability - only Microsoft could tell
you why.
 
F

frogman

is the only way to get the results i want, to make it = to all the
colors but red?
 
H

Helmut Weber

Hi Frogman,

can you make any assumptions about the text?
If it is only about words or any other pattern,
which isn't red, then:

Sub FindNotRed()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = "<*>"
.MatchWildcards = True
While .Execute
If rDcm.Font.Color <> wdColorRed Then
' rDcm.Select ' for testing only
rDcm.Font.Color = wdColorBlue
End If
Wend
End With
End Sub

You might have to redefine the range,
depending on what you do to it.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top