Home > Software engineering >  Change Project Title using Macros in MS Project
Change Project Title using Macros in MS Project

Time:11-18

I have created a roll-up Master Project using a VBA macro that grabs all MS project files in a given directory and adds them to my Master Project file. Everything works well but the title these subtasks get added as uses the Project Title (found in File->Info->Project Information->Advanced Properties->Title) instead of the Filename.

I will not be the only person creating these files so I can't guarantee the Title is accurate. What I would like to do is, using a macro, every time a MS Project file is opened it checks if the Title is different than the Filename and if so sets the Title to whatever the Filename is. My issue is, I cannot find a property of the Project object or a method that allows me to access the Project Title. Can anyone help out with how I might accomplish this.

An alternative solution would also be to add the Projects to my Master Project using the Filename instead of the Title but I also haven't figured out how I can accomplish that. To add the projects as subtasks I loop through all .mpp files in a given direction using the following line:

ConsolidateProjects Filenames:=projPath & projFile, NewWindow:=False, HideSubtasks:=True, AttachToSources:=False

Any help would be greatly appreciated.

CodePudding user response:

Try this construct. This first item in the properties is Title. activeproject.BuiltinDocumentProperties(1)

CodePudding user response:

There are several ways to do this:

ProjectObject.Title

ProjectObject.ProjectSummaryTask.Name

ProjectObject.Tasks.UniqueID(0).Name

ProjectObject.BuiltInDocumentProperties(1)

ProjectObject.BuiltinDocumentProperties("Title")

each of these will return the title of the project and can be used to set the title of the project. Note - ProjectObject is just the example variable name I'm using to represent a project object in code.

  • Related