更改word宏中的多个字符的颜色

时间:2016-08-23 08:46:30

标签: vba ms-word word-vba

我需要改变所有元音的颜色,我发现一段代码不变,请你帮忙把它改成字母组,即a,e,i,o,u?

Sub ChangeLetterColor()
    Const LETTER_TO_CHANGE = "a"
    Const COLOR_TO_CHANGE_TO = wdRed

    For i = 1 To ThisDocument.Range.Characters.Count
        If ThisDocument.Range.Characters(i) = LETTER_TO_CHANGE Then
            ThisDocument.Range.Characters(i).Font.ColorIndex = COLOR_TO_CHANGE_TO
        End If
    Next
End Sub

0 个答案:

没有答案