Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub RunMacroOnAllFilesInFolder()
- Dim flpath As String, fl As String
- flpath = InputBox("Please enter the path to the folder you want to run the macro on.")
- If flpath = "" Then Exit Sub
- If Right(flpath, 1) <> Application.PathSeparator Then flpath = flpath & Application.PathSeparator
- fl = Dir(flpath & "*.docx")
- Application.ScreenUpdating = False
- Do Until fl = ""
- MyMacro flpath, fl
- fl = Dir
- Loop
- End Sub
- Sub MyMacro(flpath As String, fl As String)
- Dim doc As Document
- Set doc = Documents.Open(flpath & fl)
- 'Do stuff
- doc.Save
- doc.Close SaveChanges:=False
- End Sub
Add Comment
Please, Sign In to add comment