Dim myDoc As Document
Dim myPath$, myFile$, FindFont$, ReplFont$, i%
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "选择目标文件夹"
If .Show <> -1 Then Exit Sub
myPath = .SelectedItems(1) & "\"
End With
Application.ScreenUpdating = False
FindFont = "仿宋": ReplFont = "宋体"
myFile = Dir(myPath & "*.doc?")
Do While myFile <> ""
On Error Resume Next
Set myDoc = Documents.Open(myPath & myFile, Visible:=False)
On Error GoTo 0
If myDoc Is Nothing Then Set myDoc = Documents(myPath & myFile)
With myDoc
With .Content.Find
.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = True
.Font.NameFarEast = FindFont
With .Replacement
.ClearFormatting
With .Font
.NameFarEast = ReplFont
.Size = 16
.Color = wdColorAutomatic
End With
End With
.Execute Replace:=wdReplaceAll
End With
.Save: .Close: i = i + 1
End With
Set myDoc = Nothing
myFile = Dir
Loop
Application.ScreenUpdating = True
MsgBox "共转换" & i & "个文件"
End Sub