View Single Post
 
Old 04-18-2025, 08:40 PM
leaning leaning is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Jan 2011
Posts: 19
leaning is on a distinguished road
Default Highlight a line of text if it only contains black characters.

Hello! I have bulleted text that I run many macros on and they change the words different colors depending on what they find.

What I am trying to do now with a macro is what I am doing manually: look for every line that is just wdAutomatic black. No other colors. If it's just black, that line of text requires more work so that one of the other macros will catch it.

Here is the code I started, but it's missing the "loop through all the lines on the page" part.

<code>
Sub JustBlack()
'
' JustBlack Macro: If the line only has black text and no other colors, then highlight that line yellow.
'
Selection.Find.Execute
Selection.Find.ClearFormatting
Selection.Find.Font.Color = wdColorAutomatic
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Range.HighlightColorIndex = wdYellow
End Sub
</code>

I appreciate your help!!
Reply With Quote