Stop and Resume a Task in VSTO and Aspose.Tasks

A task’s stop date is the date that it should (or did) end. Sometimes, a task has to be stopped temporarily and then resumed later. Microsoft Project can calculate stop dates, or let users enter them manually.

Code Examples

VSTO

Below is the code of VSTO Project to Stop and Resume a task:

 1object missingValue = System.Reflection.Missing.Value;
 2Application.FileOpenEx("MyProject.mpp",
 3    missingValue, missingValue, missingValue, missingValue,
 4    missingValue, missingValue, missingValue, missingValue,
 5    missingValue, missingValue, PjPoolOpen.pjPoolReadOnly,
 6    missingValue, missingValue, missingValue, missingValue,
 7    missingValue);
 8Project project = Application.ActiveProject;
 9Task MyTask = project.Tasks[1];
10// Stop a Task
11dynamic StoppedDate = MyTask.Stop;
12// Resume a Task
13dynamic ResumeDate = MyTask.Resume;

Aspose.Tasks

The Stop and Resume properties exposed by the Tsk class are used to read or write a task’s stop and resume date:

Microsoft Project view of Stop and Resume Dates

To see a task’s stop and resume dates:

  1. In the Task Entry form, on the Inset menu, select Column.
  2. Add the Stop and Resume columns.

Getting Stop and Resume Dates

The stop and resume dates are NA, if the task has never stopped. For date values equal to NA, Aspose.Tasks takes the value “1/1/2000” if you’re using the evaluation version. When fully licensed, Aspose.Tasks uses DateTime.MinValue for NA values. The following examples displays the stop and resume dates for all the tasks in a project.

1Project project = new Project("MyProject.mpp");
2Task MyTask = project.RootTask;
3// Stop a Task
4DateTime StoppedDate = MyTask.Stop;
5// Resume a Task
6DateTime ResumeDate = MyTask.Resume;

Download Running Code

Download Sample Code

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.