Free Support Forum -

Unable to extract a list of tasks from an mpp file

Just trying your product for the first time in Vis Studio 2008 and VB. Trying to extract a list of tasks from an mpp file. No idea what version of MS Project that this file was created in but your libraries show no tasks. Can you tell me what is wrong

Dim rdr As New ProjectReader
Dim prj As Aspose.Tasks.Project = rdr.Read(New FileStream(“F:\JOBS\Mgl\15300 Series\15378 SRC 14 Dock RAH Build Project\Pre Contract\Programme\FNF SRC 14 Dock RAH Build Project.mpp”, FileMode.Open))
Dim alTasks As ArrayList = prj.RootTask.Children
MsgBox(“No. of tasks found=” & Format$(alTasks.Count))

Hi Martin,

Thanks for writing to Aspose.Tasks support team and accept our apology for delayed response.

Please give a try to the following code which retrieves all the tasks in the mpp file and displays the task names.

’ Create a project reader instance
Dim reader As ProjectReader = New ProjectReader()

’ Read the project file
Dim project As Project = New Project()

project = reader.Read(“C:/FNF SRC 14 Dock RAH Build Project.mpp”)

’ Create a ChildTasksCollector instance
Dim collector As Aspose.Tasks.Util.ChildTasksCollector = New Aspose.Tasks.Util.ChildTasksCollector()

’ Collect all the tasks from RootTask using TaskUtils
Aspose.Tasks.Util.TaskUtils.Apply(project.RootTask, collector, 0)

’ Parse through all the collected tasks
For Each Task In collector.Tasks
If Not String.IsNullOrEmpty(Task.Name) Then
Console.WriteLine("Task Name : " & Task.Name)
End If

Please feel free to write us back if you have any other query in this regard.

Thank you. This does work although a little harder to understand. You may like to know that your website based example of extracting task list also does not work so perhaps the coding on this also needs to be updated!