
Tips.Net > WordTips Home > Normal > Searching for Special Characters > Searching for Non-Black Text
Summary: Searching for text having (or not having) specific formatting is generally pretty easy. It is more difficult to search for text that is not a particular color. This tip explains how you can find just want you want by using a macro. (This tip works with Microsoft Word 97, Word 2000, Word 2002, Word 2003, and Word 2007.)
When searching for text in a document, it is easy to search for formats such as "bold" or "italic." You can also search for "not bold" and "not italic." You can search for text of a specific color, but Word does not allow you to search for text other than a specific color. For instance, you cannot search for text that is "not black."
If you need to search for text that is not black, then the best way to do so is with a macro. Consider the following macro, which prompts you for your search text, and then looks for the first non-black instance of that text.
Sub FindNotBlack()
With Selection.Find
.ClearFormatting
.Text = InputBox(prompt:="Enter the search text.", _
Title:="Find Nonblack Text")
Do While .Execute
With Selection.Font
If (.Color <> wdColorAutomatic) And _
(.Color <> wdColorBlack) Then
MsgBox "Found"
Exit Sub
End If
End With
Loop
End With
End Sub
Note that the macro checks to see if the color of the matched text is different from black (wdColorBlack) and from the automatic color (wdColorAutomatic). This is because the automatic color is black on most systems.
Tip #1387 applies to Microsoft Word versions: 97 2000 2002 2003 2007
Find and Replace Almost Anything! An invaluable resource for learning how to harness the full power of Word's search and replace capabilities. You'll discover everything you need in order to master all the intricacies of finding and replacing elements of your document, including the super-powerful ?wildcard searches? available in Word.
Check out WordTips: Find and Replace today!
If you provide support and help to others, you need the power offered in the WordTips Ten-Year Library. There is no better information repository anywhere! (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips