VBA: Looping Through Tasks

S

StGhurka

I am trying to loop through all of the tasks in my project file an
replace some invalid values of Unique ID Predecessors (e.g. ol
predecessor is "c:\projectfile\1234" and I want it to be "5678"

I have 12000 tasks, but the following loop exits at 414. It doesn'
error or fail, it just falls out the bottom of the outer loop as i
there are no more tasks. It DOES update the value but then it jus
steps its way out of the loop.

If I do not replace that predecessor, the loop continues.

Dim TS As Tasks
Dim T As Task

For Each T In TS
If Not T Is Nothing Then
If Not T.Summary Then
For Each Pred In T.PredecessorTasks
' --lots of code to find the correct new predecessor
Pred.UniqueIDPredecessors = Replace(Pred.UniqueIDPredecessors
stepArray(i), returnID)
next Pred
end if
end if
next T

Why would changing the predecessor have that affect
 
J

Jack Dahlgren MVP

I do not think that Replace is being used correctly here. It should return a
value of True if the replacement is successful and setting
Pred.UniqueIDPredecessors to "True" does not seem to make any sense to me.
There is not enough of the surrounding code to figure out what else is wrong
or how to fix it.
You should probably post all of it if you want further help.

-Jack Dahlgren
 
S

StGhurka

Never mind - actually. I see I was updating the wrong value. It stil
doesn't seem that it should drop out of the loop, but fixing the valu
that's updated corrected the problem
 

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