none
Add recurring task in Project 2010

    Question

  • Hiya's,

    i'm currently working on a MS Project AddIn and i'm having difficulties figuring out the programming model for Project. It seems that Microsoft.Office.Interop.MSproject is not greatly documented?...

    I've managed to add one single task (which was shown somewhere in an example) to the active Project Sheet.

    MSProject.Application app;
    app = Globals.ThisAddIn.Application;
    
    MSProject.Task newTask = app.ActiveProject.Tasks.Add("test"); 
    newTask.Start = DateTime.Now; 
    newTask.Duration ="3"; 
    newTask.ResourceNames ="me, myself, I";

    But i'm unable to figure out how to turn this task into a Recurring task.

    Any hints?

     

    Regards,

     

    Wednesday, February 23, 2011 1:23 PM

Answers

All replies

  • Hi Ruben,

    Thank you for posting and we are glad to help with you.

    After reading your post, I did some research about Project Object Model to turn the task into a recurring task. But I also didn’t succeed. I think it is not possible to change an already existed task to be a recurring task, because it needs to put some parameters in the Recurring Task Information pop up window.

    Besides, it also can't be achieved from UI not mention through code. If you create a task in Gantt chart and insert a task, then select the task, and try to change it to be recurring task, it will add a new recurring task.

    So, just insert a recurring task like this:

                MSProject.Application app;
                app = 
    Globals
    .ThisAddIn.Application;
                app.RecurringTaskInsert(); 

    Here is the Project Object Model for you to reference:http://msdn.microsoft.com/en-us/library/bb277489(v=office.12).aspx

    I hope these can help you and feel free to follow up after you have tried.

    Best Regards,

     


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, February 24, 2011 4:02 AM
  • Hi Bruce,

    thanks for your quick reply.  Although your solution will eventually add a recurring task, its not exactly what I'm trying to achieve.

    The goal is to programatically add a recuring task between StartDate and Endate of the project.. (without prompting the user).

    Regards,

     

    Ruben

    Thursday, February 24, 2011 8:20 AM
  • Hi Ruben,

    It can't be achieved programmatically, the Project Object Model doesn't provide these properties for us to set the StartDate and EndDate. You should manually add it in the project application.

    Thank you for your understanding.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, February 24, 2011 8:29 AM
  • Hi Bruce,

    so I guess its best to create multiple tasks as OutlineChildren of a main task (which will be the closest thing to a recurring task)?

    Regards,

    Ruben

     

     

    Thursday, February 24, 2011 8:40 AM
  • Hi Ruben,

    The OutlineChildren property returns a task collection representing the children of a task in the outline : http://msdn.microsoft.com/en-us/library/bb211305(v=office.12).aspx

    And I think you may add it to the main task, here is a similar problem: http://www.mombu.com/microsoft/microsoft-project-developer/t-add-new-task-to-outlinechildren-collection-using-vba-1415312.html

    Hope these can help you.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Ruben van Gogh Monday, February 28, 2011 8:11 AM
    Friday, February 25, 2011 6:44 AM