我正在尝试使用宏来查找和替换 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
帮助?