我正在文档中搜索特定文本,删除文本,然后添加分节符。我只能让这段代码适用于一个实例。当我尝试使用 do while 循环检查每一行时,Word 崩溃了。
With Selection.Find
.Text = "INSTRUCTOROVERVIEW"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Selection.InsertBreak Type:=wdSectionBreakNextPage