我正在尝试突出显示所有单词,但目前它是在区分大小写的基础上进行的,我想避免这样做。
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