Hi could you help me please?
I'd like to create a macro "launch_mod_macro" in order to apply the following macro "mod_macro" on all "*.dot" file in "c:\test_macro".
The "mod_macro" changes some words of the layout, saves and closes the active file.
I find that the "ExecuteApplyMacroToAllFiles" macro can execute the macro "MyMacro" on each file in "C:\test folder" , but it doesn't work and I don't know why.
Please find below the macro:
Sub ExecuteApplyMacroToAllFiles()
'Change the path to the main folder
Call ApplyMacroToAllFiles("C:\test folder")
End Sub
Sub ApplyMacroToAllFiles(ByVal MyPath As String)
Dim FileSys As Object
Dim objFolder As Object
Dim objSubFolder As Object
Dim objFile As Object
Dim wkbOpen As Workbook
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set objFolder = FileSys.GetFolder(MyPath)
Application.ScreenUpdating = False
For Each objSubFolder In objFolder.SubFolders
For Each objFile In objSubFolder.Files
Set wkbOpen = Workbooks.Open(filename:=objFile)
'Change the name of your macro
Call MyMacro
wkbOpen.Close savechanges:=True
Next
Call ApplyMacroToAllFiles(objSubFolder.Path)
Next
Application.ScreenUpdating = True
End Sub
Please can someone help me?
thank you very much