我创建了一个循环到文档末尾的搜索和替换宏,如下所示:
Sub CheckEnglishAndTypos()
Do Until ActiveDocument.Bookmarks("\Sel").Range.End = ActiveDocument.Bookmarks("\EndOfDoc").Range.End
'Loop the search till the end
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Paragraphs(1).Range.Select
With Selection.Find
.Text = "(<*>) \1"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Loop
' Searching the remaning (till the end of document)
Exit Sub
End Sub
问题是,如果文档有任何脚注,并且搜索移动到脚注,它将给出“请求的集合成员不存在”错误。显然,如果选择/光标在脚注内,并且文档在脚注所在的页面后面有页面,则宏无法找到文档的结尾。
有没有办法修复它?从搜索中排除脚注的方法很酷,但我对任何其他替代解决方案持开放态度。