none
MS Project to detect task level changes and record a date modified in custom field RRS feed

  • Question

  • I need to know the date and time that a task field (mainly task name, start, finish) has been changed.  I found this topic within EE and it works great but...

     

    http://www.experts-exchange.com/Software/Office_Productivity/Project_Management/Q_27879745.html#a38636192

     

    If (for instance) you change a duration which affects predecessors and only the task that you changed gets a date/time stamp.


    Wednesday, August 20, 2014 4:41 PM

All replies

  • RJTMEYER,

    Don't know about the link reference, they want me to sign up just to see the solution and I'm not interested. Did you post this question to EE to get their response?

    Short of EE coming through with an answer, have you looked at change highlighting? It's one of those "hidden" features that you have to add to the ribbon, but it will show all changed cells when you make a change as you describe.

    John

    Wednesday, August 20, 2014 6:57 PM
  • John,

    Thanks for the help.

    I have posted this to EE and received one response from the guy who answered the question in the link I provided.  Here is his recommendation to a similar question (underlined at end) and it works great but does not work for changes to successors.  Only the record that receives the actual change gets stamped.

    I did think of the change highlighting but not sure how to take advantage of it.  I need to know the order that the changes occur in a session as well as the time of day.  That is why I thought a time date/time stamp would work for both. 

    Is there and event for rescheduling of successors?

    What is project looking at to see changes for the "change highlighting" format.  Is it an event that can be captured.

    Hi,

    the pointer to events above is correct. This is what you need to do:

    1. in Microsoft Project open the VBA Editor (Alt+F11). On the left side you'll see the "ProjectExplorer". Expand the "ProjectGlobal (Global.MPT)" piece.

    2. In the first section of "ProjectGlobal(Global.MPT)
    " you see "Microsoft Project Objects" and below that "ThisProject(Global.MPT)".Doubleclick it and insert the text between the --- into the Editor window on the right.
    ---
    Sub Project_Open(ByVal pj As Project)

        Call modEvents.StartEvents

    End Sub
    ---

    3.  In the second section "Modules" add a new MODULE. Name it "modEvents". Copy the text between the --- into the new module:
    ---
    Private oMSPEvents As clsEvents

    Sub StartEvents()

            Set oMSPEvents = New clsEvents
           
    End Sub
    ---

    4. In the third section "Class Module" insert a NEW CLASS MODULE. Name it "clsEvents". Doubleclick and insert the text between the --- into it
    ---
    Private WithEvents MyMSPApplication As Application

    Private Sub Class_Initialize()

        Set MyMSPApplication = Application

    End Sub

    Private Sub MyMSPApplication_ProjectBeforeTaskChange(ByValtsk As Task, ByVal Field As PjField, ByVal NewVal As Variant, Cancel As Boolean)

        tsk.Date1 = Now()

    End Sub
    ---

    Sounds like hell? Yes, but that's how it works: the first part is always executed when you open a project -> the "StartEvents" initialises the new class and tells Microsoft Project to use events (which is does NOT in the default). The last part "watches" all changes and whenever you change something it sets the Date1 field to the current date and time.

    Please let me know if you need any help!
    Regards
    Thomas

    Thursday, August 21, 2014 3:11 PM
  • RJTMEYER,

    The only methods available for change highlighting in VBA are to enable it or toggle it (see object browser for details). And no, there is no method or event for schedule "chain reactions" (i.e. successor changes).

    I just tried a little test case and apparently it is possible to detect the font color applied by change highlighting using the FontColor property of a cell. However, it also looks like the change highlighting is only visible for a period of time and attempting to detect all cells in the schedule that are highlighted may not be practical.

    Let me offer an alternative indirect approach. Changes between versions of a given file can be detected and displayed using the Compare Project utility found under the Reports group of the Project ribbon. That might be your best option.

    John

    Thursday, August 21, 2014 4:23 PM
  • As John says. I'm pretty sure, especially after a quick test, that the change event only fires for a change to the active task. No date recalculations or changes to predecessors or successors trigger the change event.

    Any date stamp will only be recorded for the last change. You could export all change details to a database, store changes in an array then save to db in the beforesave event. You would still need to evaluate what effect any change had.


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

    Thursday, August 21, 2014 8:36 PM
    Moderator
  • I realize this is quite old, but I found the exact same solution as above to help track when a task is updated.  However, after following instructions it does not work for me.  I get a syntax error when attempting to debug the macro.  The debugger stops and highlights the very first item - Sub StartEvents()

    Not really knowing much about VB or Project, I'm not sure if this is a "real" syntax error or something else with Project.


    EDIT - the syntax error appears to be in this statement - Set oMSPEvents = New clsEvents
    Monday, December 4, 2017 3:28 PM
  • I figured this out (found another example), but I think I need another lesson in the different between public and private objects - LOL.  Ultimately, it could have been that the syntax error was hidden characters in a trailing space – DOH.  I don’t know if all of these changes were truly necessary.

     

    Anyway, if you are interested here was the text I used.  This is based mostly off the above example

     

     

     

    Sub Project_Open(ByVal pj As Project)

        'MsgBox "Hello World"

     

    Call modEvents.StartEvents

     

     

    End Sub

     

     

    ==========

     

     

    Public oMSPEvents As New clsEvents

     

    Sub StartEvents()

       

        'MsgBox "startevents"

       

        Set oMSPEvents.MyMSPApp = MSProject.Application

    End Sub

     

     

     

    ==========

     

    Public WithEvents MyMSPApp As MSProject.Application

     

    Private Sub MyMSPApp_ProjectBeforeTaskChange(ByVal tsk As Task, ByVal Field As PjField, ByVal NewVal As Variant, Cancel As Boolean)

       

        tsk.Date1 = Now()

     

    End Sub

    Tuesday, December 5, 2017 4:22 AM