I have a list of excel files (some hundreds), and every files contains a macro to update some data.
Now I want to create a script that opens every single file and call the macro inside the opened file so these data are updated in every file.
So I created a new excel file called "call_all_macros.xlsm" and I created the script to iterate through all the files and call the macro. Unfortunatelly it is not working, it iterates correctly, it seems that it calls the macro and saves it, but in fact the data are not updated (althought the file is beeing saved).
This is the code I use to do the call of the macro, sometimes it is not working here:
For Each fileName In fileCollection
Set wb = eApp.Workbooks.Open(fileName)
wb.Application.Run macro_to_be_called
wb.Save
wb.Close
Debug.Print "Processed " & fileName 'Print progress on Immediate window
Next fileName
Everything is working except the macro that is not being called. Am I doing something wrong?
The called macro take the ActiveWorkbook and write some data in some cell in the ActiveWorkbook. Maybe it has a conflict in figuring out what the Activeworkbook is?