【发布时间】:2021-01-08 14:46:28
【问题描述】:
我想为 文件夹和子文件夹中的所有 doc 和 docx 文件执行 Word 宏。我的代码只执行文件夹的宏(而不是子文件夹)。有没有办法做到这一点?
到目前为止我的宏:
Sub Aufruf()
Dim File
Dim path As String
' Path to your folder. MY folder is listed below. I bet yours is different.
' make SURE you include the terminating "\"
path = "C:\Users\RHU\Desktop\VBA\"
File = Dir(path & "*.doc*")
Do While File <> ""
Documents.Open fileName:=path & File
' This is the call to the macro you want to run on each file the folder
Call Datumsfelder
' Saves the file
ActiveDocument.Save
ActiveDocument.Close
' set file to next in Dir
File = Dir()
Loop
End Sub
【问题讨论】: