ピリオドの後に 2 つ以上のスペースが続く次のスクリプトがありますが、私が探しているのは、文の最初の単語を検索できるようにすることであり、それが「Medical」の場合はそれを変更します。このスクリプトを活用したいと思っていましたが、それが段落の最初の単語であるかどうかはすでにわかります。また、「.Medical」を適切に検索する方法もわかりません。
With Selection.Find
.ClearFormatting
.Highlight = False
.Replacement.ClearFormatting
.Replacement.Highlight = True
.Text = (\.)( {2,9})
.Replacement.Text = "\1 "
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
リンクで別の投稿を見つけて、これを思いつきました:
Dim i As Integer
Dim doc As Document
Set doc = ActiveDocument
For i = 1 To doc.Sentences.Count
If doc.Sentences(i).Words(1) = "Medical " Then
doc.Sentences(i).Words(1) = "Medical (needs removal) "
End If
If doc.Sentences(i).Words(1) = "Dental " Then
doc.Sentences(i).Words(1) = "Dental (needs removal) "
End If
If doc.Sentences(i).Words(1) = "Life " Then
doc.Sentences(i).Words(1) = "Life (needs removal) "
End If
If doc.Sentences(i).Words(1) = "Vision " Then
doc.Sentences(i).Words(1) = "Vision (needs removal) "
End If
Next