【发布时间】:2013-08-20 18:56:43
【问题描述】:
我正在尝试创建一个宏,它将搜索文档并突出显示每个出现的空格,单词“for”,然后使用来自该站点的修改代码,然后像这样的另一个空格“for”,我得到了这个:
Sub findfunction()
If (findHL(ActiveDocument.Content, "[ for ]")) = True Then MsgBox "Highlight Comma's and Coordinating Conjunctions Done", vbInformation + vbOKOnly, "Highlight Result"
End Sub
Function findHL(r As Range, s As String) As Boolean
Options.DefaultHighlightColorIndex = wdYellow
r.Find.Replacement.Highlight = True
r.Find.Execute MatchWholeWord:=True, FindText:=s, MatchWildcards:=True, Wrap:=wdFindContinue, Format:=True, replacewith:="", Replace:=wdReplaceAll
findHL = True
End Function
问题在于它仅突出显示字母 f、o 和 r 的每次出现。我希望它仅在找到序列“ for”时突出显示,而不是单个字符。我是新手,我不确定从这里去哪里,所以任何帮助将不胜感激。谢谢:D
【问题讨论】:
标签: vba replace highlight ms-word