problem with for loop

T

theintern

Can anyone tell me why it's changing the constraint of the first task?

FilterApply Name:="Actually Started"
Set ts = ActiveSelection.Tasks
For Each t1 In ts
If Not ts Is Nothing Then
SetTaskField Field:="Constraint Type", Value:="Must Start On",
AllSelectedTasks:=True
SetTaskField Field:="Constraint Date", Value:=t1.Start,
AllSelectedTasks:=True
End If
Next t1

thanks!

scott
 
T

theintern

i think this does it. i realized it right after i posted.

FilterApply Name:="Actually Started"
SelectAll
Set ts = ActiveSelection.Tasks
SelectRow row:=0
For Each t1 In ts
SetTaskField Field:="Constraint Type", Value:="Must Start On",
AllSelectedTasks:=True
SetTaskField Field:="Constraint Date", Value:=t1.Start,
AllSelectedTasks:=True
SelectRow row:=1
Next t1
 
J

Jack Dahlgren

This would be better I think:

Sub intern()
Dim t As Task
Dim ts As Tasks
Set ts = ActiveProject.Tasks
For Each t In ts
'write code to filter for your selection
'if it meets the criteria then
t.ConstraintType = pjMSO
t.ConstraintDate = t.Start
Next t
'end if for the filtering criteria
End Sub

Of course, if as your code implies, the tasks have already started then you
will have an actual start date which will keep them in place. No constraint
is needed at all. I guess I don't understand why you are doing this.

-Jack Dahlgren
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top