Set Predecessor in MS Project using Python

This quick guide describes how to set predecessor in MS Project using Python. It has information about setting up the development environment, a set of programming instructions, and sample code for adding a predecessor in Microsoft Project using Python. Enhancements will also be discussed for the sample code to create a custom output MPP file.

Steps for Adding Predecessors in MS Project using Python

  1. Set up the environment by adding Aspose.Tasks for Python via .NET to create predecessor tasks
  2. Apply the product license to generate output in MPP format
  3. Generate a new project by setting its start date and name
  4. Add multiple tasks to the project and assign duration in days for each task
  5. Link a few tasks in sequence, such that each task starts before the previous task is finished
  6. Link more tasks by adding a gap between them
  7. Save the project in MPP or any other supported format
  8. Print out each task showing its predecessor and successor

These steps describe adding the predecessor in project plan using Python. Apply the license, create a new project, add a few tasks, and set each task duration. Finally, link tasks with other tasks using the TaskLinkType finish-to-start, add some lag between the tasks, and save the project on the disk.

Code for Setting Predecessors in MS Project using Python

This code describes using predecessor tasks in project management using Python. You may control working days/hours for schedules by assigning a project-level default calendar explicitly instead of relying on the built-in default calendar. If you want to refer to tasks in other projects, set the cross_project / cross_project_name properties on a link.

This guide teaches you how to work with the predecessor and successor tasks. To add milestone tasks in a project, refer to the article Add milestone in MS Project using Python.