我创建了一个search-& -replace宏,它循环到文档的末尾,如下所示:
equals
问题是,如果文档有任何脚注,并且搜索进入脚注,则它将给出“收集的请求成员不存在”错误。显然,如果选择/光标位于脚注内,则宏无法找到文档的末尾,并且文档的页面位于脚注所在的页面之后。
无论如何要解决它?从搜索中排除脚注的方法很酷,但我对任何其他替代解决方案持开放态度。
答案 0 :(得分:0)
试试这个,它应该做整个文件
Sub CheckEnglishAndTypos()
Options.DefaultHighlightColorIndex = wdBlue
' Options.DefaultHighlightColorIndex = wdYellow
With ActiveDocument.Content.Find
.ClearFormatting
.Text = "(<*>) \1"
.Replacement.Text = ""
.Replacement.ClearFormatting
.Replacement.Highlight = True
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End Sub
答案 1 :(得分:0)
搜索字符串是问题
Sub CheckEnglishAndTypos()
Options.DefaultHighlightColorIndex = wdBlue
' Options.DefaultHighlightColorIndex = wdYellow
With ActiveDocument.Content.Find
.ClearFormatting
' .Text = "(<*>) \1" ' really slow
.Text = " ([A-Za-z]@) \1"
.Replacement.Text = ""
.Replacement.ClearFormatting
.Replacement.Highlight = True
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End Sub