MS Project - How to assign task's resource cost? RRS feed

  • Question

  • Hello all!

    I am developing the MS Project 2013 Add-In and I stuck with this case. I need to assign task's resource cost. How to do that in MS Project? Go to Task Information, then Resource card and assign cost to resoruce. Ofcourse, the resource must be a Cost type. Here is my code:

    MSProject.Application app = this.Application;
    MSProject.Project project = app.ActiveProject;
    MSProject.Resource newResource = project.Resources.Add("Some Resource");
    newResource.Type = MSProject.PjResourceTypes.pjResourceTypeCost;
    MSProject.Task newTask = project.Tasks.Add("Test Task");
    newTask.Assignments.Add(newTask.UniqueID, newResource.UniqueID);

    Above code creates a new resource and sets the type to Cost, then creates new task and make assignment between each. But I don't know how to assign the costs... 

    Wednesday, March 18, 2020 5:25 PM


  • I have found solution. It was very simple -_-

    newTask.Assignments.Add(newTask.ID, newResource.ID).Cost = 10;

    Thursday, March 26, 2020 7:57 AM