7,785
社区成员




MsgBox App.Path & "\test\1.doc"
Private Sub Command2_Click()
Dim wordObj
On Error GoTo ErrHandler
10 Set wordObj = CreateObject("Word.Application")
Const TMPFILE = "~1.doc"
20 If Dir(App.Path & "\test\" & TMPFILE) <> "" Then
30 Kill App.Path & "\test\" & TMPFILE
40 End If
50 FileCopy App.Path & "\test\1.doc", App.Path & "\test\" & TMPFILE
60 With wordObj.Documents.Open(App.Path & "\test\" & TMPFILE)
70 .Content.Find.Execute "1", , , , , , , , , "A", 2
80 .SaveAs
90 End With
100 wordObj.Quit
110 If Dir(App.Path & "\test\输出报告1.doc") <> "" Then
120 Kill App.Path & "\test\输出报告1.doc"
130 End If
140 Name App.Path & "\test\" & TMPFILE As App.Path & "\test\输出报告1.doc"
ExitEntry:
Exit Sub
ErrHandler:
MsgBox Err.Description & vbCrLf & Erl, vbExclamation
Resume ExitEntry
End Sub