我正在尝试为项目创建一个vsto加载项,我正在从msdn
开始学习本教程 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";
}
在这部分中,他们教授如何创建任务。现在我想从现有项目中读取任务,但我没有在网上找到示例。我怎样才能做到这一点?
答案 0 :(得分:0)
Microsoft Project的c#示例不多。查找VBA示例并根据需要进行翻译。这是documentation for the object model。向下滚动查看Task
对象以查看其属性和方法。
通读SO posts with the ms-project tag以查看代码示例。
答案 1 :(得分:0)
这是我发现阅读任务的方式:
// 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;