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
- A subproject is an external project file referenced within a master project.
- Subprojects help organize complex projects by dividing them into separate files while keeping them linked.
- In Aspose.Tasks, setting the
SubProjectName
property on a task allows you to link it to another project file programmatically.
Checking in Microsoft Project
In Microsoft Project, you can insert a subproject by:
- Going to Project > Subproject.
- Selecting the project file you want to insert.
- 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
- Subprojects allow breaking down large projects into smaller files.
- In Aspose.Tasks, you simply assign the file name of the subproject to the
SubProjectName
field. - The link does not import the subproject into the master project; it creates a reference.
- Useful for project portfolio management or when several teams work on different parts of a larger project.
FAQ
Q: Can I link multiple tasks to different subprojects?
- Yes. Each task can reference a different external project file.
Q: Does Aspose.Tasks load the content of the subproject automatically?
- No. It stores a reference via
SubProjectName
. To work with the subproject itself, load it separately as aProject
instance.
Q: Does this feature work with both MPP and XML formats?
- Yes. The behavior is consistent across supported Microsoft Project formats.
Q: How does Microsoft Project display a subproject task?
- It shows as a summary task with a subproject icon, referencing the external file.