原理:
让宏自动去查找改文件夹下所有word文档,找到后打开,并对所有文档批量自动执行指定的宏。
示例代码如下:
Sub 批量操作WORD()
Dim path As String
Dim FileName As String
Dim worddoc As Document
Dim MyDir As String
MyDir = "G:\360data\重要数据\桌面\新建文件夹 (2)" '文件夹路径根据需要自己修改,需要处理的文件都放该文件夹内
FileName = Dir(MyDir & "\*.doc*", vbNormal)
Do Until FileName = ""
If FileName <> ThisDocument.Name Then
Set worddoc = Documents.Open(MyDir & "\" & FileName)
worddoc.Activate
Call 处理WORD '调用宏,换成你自己宏的名字
worddoc.Close True
FileName = Dir()
End If
Loop
Set worddoc = Nothing
End Sub
'======================下面的宏换成你自己的宏=================================
Sub 处理WORD()
ActiveDocument.Paragraphs(1).Range.Select
Selection.Font.Size = 72
End Sub