VBA MS Word Font Color

I want to read a read Word document, find any text that is marked with any color other than black, and delete it. How to find text color in VBA?

+3
source share
1 answer

Try using 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

NTN

+3
source

Source: https://habr.com/ru/post/1787328/


All Articles