【发布时间】:2020-03-08 15:10:11
【问题描述】:
我正在尝试创建一个宏,根据单词的第一个字母将文档中每个单词的颜色设置为预定义的颜色(例如,如果“a”=red,“apple”=red)。这是为了模拟grapheme-color synesthesia的具体形式。
这是我目前拥有的示例:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "a"
.MatchCase = False
.Replacement.Text = "a"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWholeWord = False
.MatchByte = False
.CorrectHangulEndings = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Replacement.Font.Color = a_color
End With
Selection.Find.Execute Replace:=wdReplaceAll
显然,这只会改变每个字母的颜色,而不是整个单词。
有没有简单的方法来做到这一点?或者有没有办法根据第一个字母找到选择?
【问题讨论】:
-
可以的,看我编辑的答案!