我正在尝试突出显示所有单词,但目前它是基于区分大小写的,我想避免这样做。
Sub Highlight_words()
Dim range As range
Dim i As Long
Dim TargetList
TargetList = Array("Array", "highlight", "With", "range", "matchcase")
' put list of terms to find here
For i = 0 To UBound(TargetList)
Set range = ActiveDocument.range
With range.Find
.Text = TargetList(i)
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute(Forward:=True) = True
range.HighlightColorIndex = wdYellow
Loop
End With
Next
End Sub
答案 0 :(得分:2)
将.MatchCase = true更改为以下内容:
.MatchCase = False
干杯