Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Processing siblings in MSP 2010

$
0
0

I am using the Text1 field to assign tasks (I am not using the resource feature to keep the scheduling simple, fyi).  I want to filter on any tasks the team members has "assigned" to them via the Text1 field but I also want to mark all the identified associated tasks that are not in a summary task but in an outline level group for filtering.   So my goal is to run a report so they can see the tasks they owns ---plus the related tasks if they are in the same non-summary task “group”. 

For my test code, I am keeping it simple and just used the team member "Painter" to see if I could get this to work.  So first I tested that I could mark tasks that were owned by the Painter that were summary tasks, and this worked fine:

---------------------------------------------------------------------------------------

Sub SiblingTestA()

Dim t As Task

For Each t In ActiveProject.Tasks

    If Not t Is Nothing and t.Summary Then

        If t.Text1 = "Painter" Then

            t.text2 = “Painter Group”

        End If

    End If

Next t

End Sub

=========================================================

Then I found some code that would mark all the sibling tasks that were in a group:

---------------------------------------------------------------------------------------

Sub SiblingTestB()

Dim MyParent As Task

Dim Sibling As Task

            Set MyParent = ActiveCell.Task.OutlineParent

            For Each Sibling In MyParent.OutlineChildren

                Sibling.text2 = "In a Sibling Group"

            Next Sibling

End Sub

=================================================

So where I got stuck is I couldn't figure out how to changeSet MyParent = ActiveCell.Task.OutlineParent

to process the current task in a for each loop; e.g. the current “t”.  I am not a programmer, but use Rod Gills book to figure out what I can, and while that is very helpful, I just cannot get it figured out. I have tried repositioning the active cell position via selecttaskfield, selectrange, etc. They all bomb.  Here is where I get stuck, and this of course does not work, it doesnt process the siblings that have Text1="Painter".

---------------------------------------------------------------------------------------

Sub SiblingTestC()

Dim MyParent As Task

Dim Sibling As Task

Dim t As Task

          

For Each t In ActiveProject.Tasks

    If Not t Is Nothing And Not t.Summary Then

        If t.Text1 = "Painter" Then

                Set MyParent = ActiveCell.Task.OutlineParent

                For Each Sibling In MyParent.OutlineChildren

                    Sibling.text2 = "In Painter Group"

                Next Sibling

        End If

    End If

Next t

End Sub

=================================================

The output I am trying to get would look like this:

Task NameText1Text2
Select colorsPainterPainter Group
Pickup suppliesHelper
Setup RoomHelper
   Tape trimHelperIn Painter Group
   Tarp, etc.PainterIn Painter Group
Paint RoomPainterPainter Group
CleanupHelper
DoneAll

Can anyone help me out here please?  Thank you.





Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>