【Word VBA】批量替换字符
很简单的Word VBA ,本例 替换 "填表日期:2019/12/31" 为 " "
Sub test() Dim T Dim doc As Document Dim fd As FileDialog Dim vrtSelectedItem As Variant Set fd = Application.FileDialog(msoFileDialogFilePicker) With fd If .Show = -1 Then For Each vrtSelectedItem In .SelectedItems Documents.Open FileName:=vrtSelectedItem Set doc = ActiveDocument With doc.Content.Find .Text = "填表日期:2019/12/31" .Replacement.Text = " " .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue End With doc.Save doc.Close T = T + 1 Next End If End With MsgBox "操作完成!!" & Chr(10) & "处理了 " & T & " 个文件。", vbOKOnly, "提示" End Sub