将自动文本颜色替换为选择中的某些显式颜色

时间:2015-02-11 10:05:13

标签: vba ms-word

如何编写一个宏,找到Font.ColorIndex = wdColorAutomatic的所有文本块并将其更改为wdColorWhite?

我需要它将富文本粘贴到Confluence wiki中带有黑色背景的面板。此背景的默认颜色为灰色。

1 个答案:

答案 0 :(得分:1)

试试这个:

Sub Test()
      With ActiveDocument.Range.Find
      .Text = "wdColorAutomatic"
      .Replacement.Text = "wdColorWhite"
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
      .Execute Replace:=wdReplaceAll
    End With
End Sub