|
论坛上已经有的代码
Sub kqbt_zh()
Application.ScreenUpdating = False
Dim MyPath As String, i As Integer, myDoc As Document
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "选择目标文件夹"
If .Show = -1 Then
MyPath = .SelectedItems(1)
Else
Exit Sub
End If
End With
With Application.FileSearch
.LookIn = MyPath
.FileType = msoFileTypeWordDocuments
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Set myDoc = Documents.Open(FileName:=.FoundFiles(i), Visible:=False)
With myDoc.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Execute findtext:="原来的字符", replacewith:="要替换的字符", MatchWildcards:=False, Replace:=wdReplaceAll
End With
myDoc.Close True
Next
End If
End With
Application.ScreenUpdating = True
End Sub |
|