Loading...
Quick Links

Warning message when indenting tasks?

Home Forums Discussion Warning message when indenting tasks?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #4932 Reply
    Community
    Keymaster

    When you indent a task, the task above becomes a summary task. If that
    task had work assigned, that information is lost, because the value
    for work is now the sum of the work of the detail tasks below the
    summary.
    Is it possible to connect a macro to the action of indenting to check
    if the to-become-summary task has work, and warn the user before the
    change is made?
    I know the task event projectbeforetaskchange, but that one does not
    fire on indenting.
    Any ideas? Thanks!

    #6331 Reply
    Community
    Keymaster
    Hello Martin Haerri –
    It is stated in Project API documentation (refer
    http://msdn.microsoft.com/en-us/library/aa204904(office.11).aspx) that ProjectBeforeTaskChange event doesn’t occur … when changes are made to outline level or outline number … — this means when you outline the tasks this event doesn’t get fired.
    I am worried you can’t do this through macros. Instead, take a copy of the "work" to "custom number1 column" and compare the differences using a flag.
    Hope this helps
    — Sai, PMP, PMI-SP, MCTS Project
    #10067 Reply
    Community
    Keymaster
    Hello Martin,
    I just tested this scenario using the ProjectBeforeTaskChange2 event.  It works like a charm.
    (I am assuming that you have created a class that allows you to enable the capture of ProjectBeforeTaskChange2 events.)
    Here’s the code I used:
        If Field = pjTaskOutlineLevel And ActiveCell.Task.OutlineLevel < NewVal Then
    If ActiveProject.tasks(ActiveCell.Task.ID – 1).ResourceNames <> "" Then
    Message "The preceeding Task has resources assigned. This change in Outline Level is not allowed."
    Info.Cancel = True
    End IfEnd If

    Changing the outline level does trigger a task change event.
    Gary Phillips, Integrated Master Scheduler, PMP
    #6372 Reply
    Community
    Keymaster
    Hello Gary
    Thanks a lot for your post, I will try it out. If it works like a charm as you say, I know a user who will be extremely happy.
    Best regards, Martin
    #6393 Reply
    Community
    Keymaster
    I got the code to work, it looks fantastic!
    I would like to make it a bit more userfriendly by prompting users and allowing them to accept this change, or not. I wrote the following code, but it gets stuck on the prompt, no matter which button I press the message box reappears. I am certainly missing some piece of information here. Thanks for any help.
        If (Field = pjTaskOutlineLevel And ActiveCell.Task.OutlineLevel < NewVal) And _
    (ActiveProject.Tasks(ActiveCell.Task.ID – 1).ResourceNames <> “”) Then
    If Response = MsgBox(“The preceeding task has resources assigned.”, vbOKCancel) = vbCancel Then
    Info.Cancel = True
    Else
    OutlineIndent
    End If
    End If
    #6394 Reply
    Community
    Keymaster
    Apologies, that was of course wrong, here’s the fixed code. However, when I click the Cancel button the execution is cancelled, but when I click the OK button the message box reappears and reappears and reappears…
        If (Field = pjTaskOutlineLevel And ActiveCell.Task.OutlineLevel < NewVal) And _
    (ActiveProject.Tasks(ActiveCell.Task.ID – 1).ResourceNames <> “”) Then
    If MsgBox(“The preceeding task has resources assigned.”, vbOKCancel) = vbCancel Then
    Info.Cancel = True
    Else
    OutlineIndent
    End If
    End If
    #6406 Reply
    Community
    Keymaster
    Martin,vb.
    Part of the problem is that the initial outlineindent command you initiated is still in process when the ProjectBeforeTaskChange2 event traps the change.
    By adding the outlineindent command again, you are triggering another outlineindent task change, which is trapped by ProjectBeforeTaskChange2 , which performs another outlineindent, which triggers another event……the result you already know.
    The outlineindent command WILL finish regardless of anything
    you execute in VB unless info.cancel is set to true.  The default value is False.
    Allowing the outlineindent to complete can also be triggering additional ProjectBeforeTaskChange2  events.  There are two things left you have to do, which is described in documents already posted to the web.  I have to go find them again, and will post the URL to the documents here as soon as I locate them.
    Gary
    From: Martin Haerri
    Posted: Friday, July 15, 2011 8:10 AM
    Subject: Warning message when indenting tasks?

    Apologies, that was of course wrong, here’s the fixed code. However, when I click the Cancel button the execution is cancelled, but when I click the OK button the message box reappears and reappears and reappears…
        If (Field = pjTaskOutlineLevel And ActiveCell.Task.OutlineLevel < NewVal) And _
    (ActiveProject.Tasks(ActiveCell.Task.ID – 1).ResourceNames <> “”) Then
    If MsgBox(“The preceeding task has resources assigned.”, vbOKCancel) = vbCancel Then
    Info.Cancel = True
    Else
    OutlineIndent
    End If
    End If
    #10069 Reply
    Community
    Keymaster
    Ah, yes, I got it, how stupid of me!
    I removed the “OutlineIndent” statement from the code and now it works perfectly, luckily it did not trigger another ProjectBeforeTaskChange2 event.
    However, I would be more than grateful if you could post the links to the documents you mentioned. Anything that can help me get more insight into these topics is more than welcome!
    Thanks again!
Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: Warning message when indenting tasks?
Your information:




62 − 52 =