Change constrainttype to pjMFO

T

tk

I am trying to change the constraint type for each task to pjMFO (must
finish on). When I do this in my macro I get an 1101 - invalid constraint
error. If I manually change the constraint for a task, it works fine. Any
ideas why I cannot change this in code?

Thanks
 
R

Rod Gill

Hi,

Try recording a macro of you changing a constraint manually and see what
code gets recorded.
 
T

tk

Here is the code I am using:

For Each ScheduledTask In ActiveProject.Tasks
If Mid(ScheduledTask.Name, 1, 1) = "I" Then
If IsNumeric(Mid(ScheduledTask.Name, 11)) Then
If CInt(Mid(ScheduledTask.Name, 11)) >= 100 Then
ScheduledTask.Delete
Else
Job = Mid(ScheduledTask.Name, 2, 4)
ScheduledTask.Name = Mid(ScheduledTask.Name, 1, 5) & "
P/N " & Trim(CStr(Dictionary.Item(Job))) & " " & Mid(ScheduledTask.Name, 12)
ScheduledTask.ConstraintType = pjMFO
ScheduledTask.ConstraintDate = ConDate.Item(Job)
End If
Else
Job = Mid(ScheduledTask.Name, 2, 4)
ScheduledTask.Name = Mid(ScheduledTask.Name, 1, 5) & " P/N
" & Trim(CStr(Dictionary.Item(Job))) & " " & Mid(ScheduledTask.Name, 12)
ScheduledTask.ConstraintType = pjMFO
ScheduledTask.ConstraintDate = ConDate.Item(Job)
End If
Else
ScheduledTask.Name = "Raw P/N " & ScheduledTask.Name
End If
Next

If I use pjFNLT or pjSNET the code runs fine.
 
J

Jan De Messemaeker

Hi,

Have you at least TRIED my suggestion on summary tasks?

If not scheduledtask.summary then
ScheduledTask.ConstraintType = pjMFO
ScheduledTask.ConstraintDate = ConDate.Item(Job)
end if
 
T

tk

After further review (I didn't write the original code), the code was
setting the constraint on
all tasks, not just the summary tasks.

Thanks for your help

Tim
 
J

Jan De Messemaeker

.....
But ALSO on the summary tasks, and that caused the error, isn't it?
 

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