简体   繁体   English

VBA MS Word字体颜色

[英]VBA MS Word Font color

I want to read read through a Word document, find any text that is marked in any color other then black and delete it. 我想阅读通过Word文档阅读,找到任何标记为黑色以外的任何颜色并删除它的文本。 How to find the text color in VBA? 如何在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 HTH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM