开发者

VBA MS Word Font color

开发者 https://www.devze.com 2023-02-06 13:01 出处:网络
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开发者_StackOverflow?Try the following code:

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开发者_StackOverflow?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号