Warning message when indenting tasks?

Home Forums Discussion Forum Warning message when indenting tasks?

Viewing 7 reply threads
  • Author
    Posts
    • #4932
      Preeti Dimble
      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
      Preeti Dimble
      Keymaster
      Hello Martin Haerri –
      It is stated in Project API documentation (refer
      https://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
      Preeti Dimble
      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
      Preeti Dimble
      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
      Preeti Dimble
      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
      Preeti Dimble
      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
      Preeti Dimble
      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
      Preeti Dimble
      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 7 reply threads
  • You must be logged in to reply to this topic.