0

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.

  • Hi @PallavN, it's a good practice to not write tags in title because Stack's tag system is good and we should trust it. See more here. – Goncalo Peres Jul 18 at 11:21
  • 1
    Hi Goncalo, OK I will take care of this. – PallavN Jul 18 at 13:51
0

Create another macro that loops through your list of projects that does this:

  1. Opens a project
  2. Runs your macro
  3. Closes and saves the project
  4. 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
  • Hi Rachel, superb. But that's what I want to know that how to loop through my list of project?. Once I get a project, that will be ActiveProject and I can handle further part. Appreciate if you could help me with that. – PallavN Jul 13 at 19:32
  • See update with basic code example. There are probably 1000 Excel questions for every Project question on the Internet but the basics are the same. Search for questions about looping through files using vba. For example search "vba loop through excel files and run macro". – Rachel Hettinger Jul 15 at 4:07
  • This way, we can drectly open file from Project Online, do work and Publish-Close. But using array is not feasible as there may be thousands of Projects. We need to run this macro on all Online Projects. – PallavN Jul 15 at 12:26
  • Hi Rachel, please let me know if you can help with this. – PallavN Jul 16 at 7:38
  • I suggest you create a new question here or on the Sharepoint site and ask specifically about listing/searching projects from Project Online, using vba. – Rachel Hettinger Jul 16 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.