New to MS Project Macro, but use to writing some level of macros in excel.

I want to write macros that apply different logic only on the predecessors of the activity or selected activities.

e.g filter only selected task and its predecessors Or find the predecessors and see which ones have been completed.

The questions is, how do I read the processors? Do I read them as a text strings and then separate them based on commas OR there is a way to define a predecessor variable / variables and then apply a filter based on task ID?

1 Answer 1

  1. A task's "Predecessors" and "Successors" attributes are text strings that you can see, print, and filter in the task table.
  2. Project builds these text strings using the task's "TaskDependencies" collection. The "predecessors" string lists all those dependencies in the collection where the "to" dependency attribute (which is actually a pointer reference to a task object) corresponds to the selected task, and the "successors" string lists those dependencies where the selected task is "from".
  3. Each task also possesses two task collections called "PredecessorTasks" and "SuccessorTasks." These collections hold pointers to the corresponding task objects but omit other dependency attributes.
  4. You can use vba to find and set flags for the predecessor (or successor) tasks of interest. Then build a filter based on the flags that you apply.
  5. If desired, you could crib from bits of vba code on my blog. (Search for "tomsblog vba code").
  • Thank you very much. That was very helpful Commented Aug 9, 2022 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.