Setting Attributes for New Tasks

Setting Attributes for New Tasks

Microsoft Project allows setting default properties for new tasks added. This topic explains how to set the default start date for new tasks using Aspose.Tasks for C++ API.

The Project class exposes the NewTaskStartDate property that defines the start date for a new task. This property supports the values defined by the TaskStartDateType enumeration type.

To see the task attribute:

  1. Open the file with Microsoft Project.
  2. On the Tools menu, select Options.
  3. Select the Schedule tab.

The tab looks like the one shown below.

New tasks set to start on the current date

edit task’s schedule options in Microsoft Project

The code example given below demonstrates how to set the new task start date.

 1// The path to the documents directory.
 2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3    
 4// Create a project instance Set new task property and Save the project as XML project file
 5System::SharedPtr<Project> project = System::MakeObject<Project>();
 6project->Set<TaskStartDateType>(Prj::NewTaskStartDate(), Aspose::Tasks::TaskStartDateType::CurrentDate);
 7project->Save(dataDir + u"SetAttributesForNewTasks_out.xml", Aspose::Tasks::Saving::SaveFileFormat::XML);
 8    
 9// Display Status.
10System::Console::WriteLine(u"New Task created with start date successfully.");
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.