Click here to Skip to main content
15,887,392 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I must write an application that reads a database and create a file mpp.

I manage to create the file and insert Task, but I can not create summary tasks.

C#
String Mission = "";
_AppMSProject = new Microsoft.Office.Interop.MSProject.ApplicationClass();
_AppMSProject.FileOpen(path, false, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Microsoft.Office.Interop.MSProject.PjPoolOpen.pjPoolReadWrite, Missing.Value, Missing.Value, true, Missing.Value);

    _AppMSProject.ActiveProject.DisplayProjectSummaryTask = true;
    int cptTask = _AppMSProject.ActiveProject.Tasks.Count + 1;

    MSProject.Task Tache = null;
    foreach (DataSet.myTableRow row in DataSet.myTable)
    {
        if (Mission != row.Mission)
        {
// Here must be SUMMARY Task
            Mission = row.Mission;
            Tache = _AppMSProject.ActiveProject.Tasks.Add(Mission, cptTask);
                        cptTask++;
            Tache.Manual = false;
        }
        Tache = _AppMSProject.ActiveProject.Tasks.Add(row.Code_type_tache, cptTask);
        Tache.Duration = row.Heures;
        Tache.Type = Microsoft.Office.Interop.MSProject.PjTaskFixedType.pjFixedDuration;
        cptTask++;
    }
    _AppMSProject.FileSaveAs(path, MSProject.PjFileFormat.pjMPP, Missing.Value, false, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, true, Missing.Value);
    _AppMSProject.Visible = true;
}


I tried using :
Tache.SetField(Microsoft.Office.Interop.MSProject.PjField.pjTaskSummary, "Yes");

But it generates an error.

How can I do This.
Posted
Updated 10-Feb-11 23:21pm
v2
Comments
Sunasara Imdadhusen 11-Feb-11 8:23am    
What is error?
guillaume.digeteca 11-Feb-11 9:28am    
The error is : "Invalid argument value"

If I use Tache.GetField(Microsoft.Office.Interop.MSProject.PjField.pjTaskSummary) I obtain the value "No"

I tried several values, but nothing works. I find nothing in the documentation

1 solution

Hi,

You can use the method _AppMSProject.InsertSummaryTask().

Here is an example:

if(_AppMSProject.InsertSummaryTask())
{
//to change the name
_AppMSProject.ActiveCell.Task.Name = "Task Summary name";

}

This is very buggy though and I still don't understand all of it, but I hope it helps.

Here is a link: http://msdn.microsoft.com/en-us/library/ff867757.aspx

Thanks,
Joseph
cyberlightsystems.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900