マクロを使用して、Word 2007 ドキュメント内のテキストを検索して置換しようとしています。テキストが見つかるたびに、置換テキストの数値を自動インクリメントしたいと考えています。
前のテキスト:
The quick brown (??) fox jumps over (??) the (??) lazy dog
次の後に必要なテキスト:
The quick brown (1) fox jumps over (2) the (3) lazy dog
何らかの理由で、私のコードは最初のインスタンスのみを置き換えます:
Sub SetRequirements()
Dim myNumber As Integer
myNumber = 1
With ActiveDocument.Content.Find
.ClearFormatting
.Text = "(??)"
Do While .Execute( _
Replace:=wdReplaceOne, _
ReplaceWith:="(" & myNumber & ")", _
Forward:=True) = True
myNumber = myNumber + 1
Loop
End With
End Sub
ヘルプ?