我有以下脚本,它将找到一个句点后跟 2 个或更多空格,但我正在寻找的是能够找到一个句子的第一个单词,如果它是“医疗”,那么它会改变它。我希望利用这个脚本,但我已经可以判断它是否是段落的第一个单词,它会被遗漏,而且我不知道如何让它正确搜索“。医疗”
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