'直接在word文件替换,不会的话,录制宏
Private Sub Command1_Click()
Dim wordApp As New Word.Application
Dim wordDoc As New Word.Document
Set wordApp = CreateObject("Word.Application")
wordApp.Visible = False
Set wordDoc = wordApp.Documents.Open("d:\2.doc")
With Selection.Find
.Text = "456"
.Replacement.Text = "999"
End With
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceAll'替换全部
End With
End Sub