ドキュメント内の特定のテキストを検索し、テキストを削除してからセクション区切りを追加しています。このコードは 1 つのインスタンスでしか機能しません。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