The code below (in standard ThisAddIn class of a VSTO add-in) retrieves info about tasks to be added to MS Project (2013) and then adds actual tasks to project Tasks collection. The problem is the Project allowing to add tasks one by one and repainting (refreshing) the project view every time a task is added to Tasks collection. It looks annoying. So far I found and used Application.ScreenUpdating property to hide the blinking.
It would be nice to prepare a collection of tasks and attach them all together to the active project. Could anyone more experienced please point towards a way to accomplish this? If it's possible at all with the current MS Project Add-In API?
Thanks a lot.
using MSProject = Microsoft.Office.Interop.MSProject;
public partial class ThisAddIn
private void ShowTasks()
MSProject.Project project = this.Application.ActiveProject;
// TaskInfo is a custom DTO type
IEnumerable<TaskInfo> dataSource = GetDataSourceSomehow();
this.Application.ScreenUpdating = false;
this.Application.Calculation = MSProject.PjCalculation.pjManual;
foreach(TaskInfo info in dataSource)
MSProject.Task task = project.Tasks.Add(info.TaskName);
this.Application.ScreenUpdating = true;
I took some time investigating but was not successful. Finally i've received an answer that it's not possible, at least with the current API (MS Project 2013):