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.
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