I have some tasks to be be performed on each project daily. I can write a macro to automate those tasks for a project. That way I have to run that macro exclusively for each project. How do I write a macro that will run on all projects and perform those Tasks.
Create another macro that loops through your list of projects that does this:
- Opens a project
- Runs your macro
- Closes and saves the project
- Repeats steps 1-3 for each project in your list*.
*Your list can be a simple array of file names.
Here is a basic code example. There are many different ways to loop through files; search stack overflow, google, etc. to find examples.
Sub RunDailyMacroOnAllProjects() Dim myProjects() As Variant myProjects = Array("Test1.mpp", "Test2.mpp") Dim prjFile As Variant For Each prjFile In myProjects FileOpenEx prjFile MyDailyMacro FileCloseEx pjSave Next prjFile End Sub Sub MyDailyMacro() ' code here End Sub