none
MS Project Pro 2013 - how to know programatically (c#) that a task has changed RRS feed

  • Question

  • Hello

    We are facing few issues in our development for MS Project Pro 2013. The issues are the following:

    We work with large mpp files, around 3000 task. Our application reads all 3000 task and save them on a localdb. The main issue is when we have to manipulate (update or insert or delete or change task dependency) a task in the middle or beginning of the file because this change can change most of the tasks  dates.

    So I would like to know if there is a way to know programmatically only the tasks that have changed. Visually it is easy because whenever you change a task all the others that are somehow related change color. Please see picture below, I changed task 3 duration and the ms project pro 2013 colored in light blue the other tasks that changed their dates.

    So, is there a way to know programmatically which tasks and work packages changed?

    Thanks.


    PL

    Monday, July 4, 2016 9:04 PM

Answers

  • You can use the

    BaselineSave All:=True, Copy:=pjCopyCurrent, Into:=pjIntoStart_Finish1

    command to copy all start/finish dates to Start1/Finish1. No need to do in loops what Project already does internally.

    You can now create a formula in a custom field to compare Start1/Finish1 to current dates then filter for any variance. Now you can copy/paste or loop only thru changed tasks.


    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Monday, July 11, 2016 9:30 PM
    Moderator

All replies

  • Pedro,

    As far as I know, there is no single property or method in VBA that will tag tasks that have triggered the change highlight filter, which is what you see with the blue background coloring. And if it not available in VBA then it certainly won't be available in C#.

    What you could do it to save certain data from each task when the file is closed or prior to update. Then after the update, compare the current data with the saved data. For example, save the Start field to the Start1 field. That may be the only data you need to save since normally a change to the Start of a task will result in a change to the finish also. Then after editing, loop through all tasks and compare Start to Start1. When there is a difference, you know that task was impacted by the edit.

    Hope this helps.

    John

    Monday, July 4, 2016 10:00 PM
  • Hi John, thanks for your help and quick answer. However, to do what you proposed for large mpp files, around 3000 tasks, is very slow with Microsoft interop, that´s why I was looking for a quicker way to track only the tasks that have changed.
    Thanks.

    Pedro


    PL

    Monday, July 4, 2016 10:08 PM
  • Pedro,

    Well if you do it with VBA instead of C# it will run very fast.

    You are aware that Project has a built-in utility for exactly that purpose, comparing two genetically related files and creating a difference file. Maybe you could just use that. No programming needed. You'll find it under Project/Reports group/Compare Projects.

    John

    Monday, July 4, 2016 10:16 PM
  • Hi John

    thanks for your reply. But VBA is not an option, there is an application developed using c# and we deal with large amounts of data simultaneously. But I will check whether we can use some built-in feature that could help us read and write large amount of data at once, instead of line by line. If you know anything else, I would gladly hear and be very thankful.

    Thanks.

    Pedro


    PL

    Tuesday, July 5, 2016 9:28 PM
  • Pedro,

    I had another thought. What if the comparison is run using VBA in Project and the results either saved to a text file, Excel or Access for further processing/analysis by your C# application? Then if you need to go the other way, (i.e. modify Project based on the analysis), reverse the process. It's not a direct method but it might allow the majority of the processing to be done most efficiently.

    Just a thought.

    John

    Tuesday, July 5, 2016 9:54 PM
  • Hi Pedro,

    You can always use the ProjectBeforeTaskChange as demonstrated here - https://msdn.microsoft.com/en-us/library/office/ff865521.aspx (example is VBA but same can be achieved with VSTO addin and c#).

    Hope this helps,

    Roy


    Royg

    Sunday, July 10, 2016 11:36 AM
  • Hi Roy

    thanks for your help. This method would work nice for smaller projects, for larger projects however,  around 5000 tasks, I would have to use a for next to find all the tasks that have changed and that would consume a lot of time. I was looking for a method that would return already a list of the tasks that have changed without the necessity of using a loop for that.

    If you know such a method I would appreciate your sharing.

    Thanks.

    Pedro


    PL

    Monday, July 11, 2016 6:35 PM
  • You can use the

    BaselineSave All:=True, Copy:=pjCopyCurrent, Into:=pjIntoStart_Finish1

    command to copy all start/finish dates to Start1/Finish1. No need to do in loops what Project already does internally.

    You can now create a formula in a custom field to compare Start1/Finish1 to current dates then filter for any variance. Now you can copy/paste or loop only thru changed tasks.


    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Monday, July 11, 2016 9:30 PM
    Moderator
  • Thanks Rod

    PL

    Tuesday, July 12, 2016 1:49 PM