如何替换所有WORD文档
来源:百度知道 编辑:UC知道 时间:2024/06/25 06:13:10
只能用宏指令来实现了:
Sub Macro1()
Dim Message, Title, Default, MyValue
Message = "请输入文件所在目录"
Title = "输入对话框"
Default = "c:\"
MyValue = InputBox(Message, Title, Default)
Dim MyFoundFiles(10000)
Dim MyFoundCount
With Application.FileSearch
.FileName = "*.doc"
.LookIn = MyValue
.Execute
MyFoundCount = .FoundFiles.Count
For i = 1 To .FoundFiles.Count
MyFoundFiles(i) = .FoundFiles(i)
Next i
End With
For i = 1 To MyFoundCount
Documents.Open FileName:=MyFoundFiles(i)
With Selection.Find
.Text = "双壁单影"
.Replacement.Text = "SD"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True