I want to read read through a Word document, find any text that is marked in any color other then black and delete it. How to find the text color in VBA?
Try the following code:
Sub DeleteNonBlack()
Dim Wrd As Range
For Each Wrd In ActiveDocument.Words
If Wrd.Font.Color<>wdColorBlack and wrd.Font.Color<>wdColorAutomatic Then
Wrd.Delete
end if
Next Wrd
End Sub
HTH
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.