2017-07-07 1 views
0

Je suis en train de créer un vsto add-in pour le projet et que je suis ce tutoriel de msdnTâches de lecture dans VSTO pour MS-Project

void Application_NewProject(Microsoft.Office.Interop.MSProject.Project pj) 
     { 
      MSProject.Task newTask = pj.Tasks.Add 
       ("This text was added by using code", missing); 
      newTask.Start = DateTime.Now; 
      newTask.Duration = "3"; 
      newTask.ResourceNames = "Rob Caron, Kelly Krout"; 
     } 

Dans cette partie, ils enseignent comment créer une tâche . Maintenant, je voudrais lire les tâches d'un projet existant, mais je n'ai pas trouvé d'exemples en ligne. Comment puis je faire ça?

Répondre

0

C'est la façon dont je trouve lire des tâches:

// Get the active project 
public static MSProject.Project ActiveProject = Globals.ThisAddIn.Application.ActiveProject; 

    // Iterating over tasks in active project 
    foreach (MSProject.Task oSubTask in ActiveProject.Tasks) 
    { 
     // Do something with the task 
    } 

    // If you want a particular task, set the index and choose the field 
    string name = ActiveProject.Tasks[1].Name;