【发布时间】:2018-03-12 06:37:54
【问题描述】:
我正在编写一个宏来删除 Word 文档中的所有突出显示颜色,除了 wdGray25(其 HighlightColorIndex 等于 15)。当宏运行到用 wdGray25 突出显示的超链接时,就会出现问题,而当 Alt+F9 显示时,该超链接/字段未突出显示。在这种情况下, Do While .Execute 循环进入无限循环并且永远不会退出。
如何重写代码以使 .Execute 方法不会进入无限循环?感谢您的帮助。
color_array = Array("2", "3", "4", "5", "6", "7", "9", "10", "11", "12", "13", "14")
For Each color_number In color_array
With Selection
.HomeKey Unit:=wdStory
With Selection.Find
.Highlight = True
.Text = ""
Do While .Execute
If Selection.Range.HighlightColorIndex = color_number Then
Selection.Range.HighlightColorIndex = wdNoHighlight
Selection.Collapse wdCollapseEnd
End If
Loop
End With
End With
Next
【问题讨论】: