Setting a Task to a Subproject

In Microsoft Project, you can link a task in the main project to another project file, treating it as a subproject. This is useful for large projects that are split into smaller, manageable parts. Aspose.Tasks for .NET provides the same functionality programmatically via the Tsk.SubProjectName property.

Understanding Subprojects

Checking in Microsoft Project

In Microsoft Project, you can insert a subproject by:

  1. Going to Project > Subproject.
  2. Selecting the project file you want to insert.
  3. Microsoft Project will display it as a summary task, which references the external project.

This summary task behaves like a placeholder, linking to the actual subproject file.

Example: Setting a Task to a Subproject

The following code demonstrates how to create a task in the master project and set it to reference a subproject file:

1Project project = new Project("New Project.mpp");
2
3// Add task
4Task task = project.RootTask.Children.Add("Task 1");
5
6// Setting new subproject link
7task.Set(Tsk.SubprojectName, "subProject.mpp");
8
9project.Save("SubProjectTask_out.mpp", SaveFileFormat.MPP);

Key Notes

FAQ

Q: Can I link multiple tasks to different subprojects?

Q: Does Aspose.Tasks load the content of the subproject automatically?

Q: Does this feature work with both MPP and XML formats?

Q: How does Microsoft Project display a subproject task?

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.