我已尝试使用this stackoverflow thread about creating a macro that highlights specific words中共享的代码,该代码适用于最多68个单词和短语,但似乎我达到了限制,并且不允许我输入其他条款。我需要能够搜索并突出显示500多个术语。
搜索字词通常有限制吗?或者有没有办法让我将宏引用到一个单独的文档,其中包含我想要识别的所有单词,而不是将每个术语输入代码?非常感谢任何指导。
我已经尝试过最多68个目标的代码,此时代码停止让我输入新条款:
Sub HighlightTargets()
'
' HighlightTargets Macro
'
'
Dim range As range
Dim i As Long
Dim TargetList
TargetList = Array("target 1", "target 2", "target 3", ... "target 68")
For i = 0 To UBound(TargetList)
Set range = ActiveDocument.range
With range.Find
.Text = TargetList(i)
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute(Forward:=True) = True
range.HighlightColorIndex = wdYellow
Loop
End With
Next
End Sub