Post by Marcelo KThank you John,
I started to play a little bit with the SplitParts collection. In order
1. I pass the original Tasks collection as parameter (named ts), so I can
find there the split parts and
For Each sp In ts(asg.TaskID).SplitParts
.Split sp.Start, sp.Finish
' tried also .SplitParts.Add sp.Start, sp.Finish
Next sp
And, even though I can see, through the watch window, the splitparts were
copied, I don't see the split in the gantt view.
For example, given the original task is a 2d task, splited into 1d on
07-Feb-06 and another 1d on 18-Feb-06.
When I copy it (by the code I poseted before) I create a new task, copy
the start date (07-Feb-06), copy the end date (18-Feb-06) and the work (960
minutes) and then copy the splitparts.
What I see in the Gantt is a single task (no visible split) with 12d
duration (7-Feb to 18-Feb).
I tried not to copy the finish date, but it did no good.
My strongest suspicion is that this is not the right way to copy a task
by program. Unfortunately it seems to be that nobody ever needed to do such a
copy, because I cannot find anywhere a pointer to some sample code for this,
not in these forums, even not google can find some useful link about it.
Marcelo,
If the split parts are indeed copied, which seems to be the case by what
you see in the watch window, then it may just be a simple matter of
making sure there is a Gantt bar format for showing the split. Go to
Format/Bar Styles for the new project file and see if there is a "bar"
for showing splits. If not create one. If there is, try creating a
little test loop that looks at all tasks in the new file and examines
the Count property of the SplitParts object. Note that any normal task
has at least one split part so look for tasks with a count of > 1. If
nothing shows up then you are probably not correctly interpreting what
the watch window is telling you and you will need to examine your code
more closely to find out why it isn't working.
As far as a right or wrong way to do something, it is more a matter of
effectiveness. In other words, does the approach you are using work? If
it does, then it is a "right" way - it may not be the most efficient way
but it certainly is "right" because it does work.
You are correct about not being able to find much information on what
you are doing. Very few, if any, users want or need to copy individual
tasks (including splits) from one file to another in the manner you
want. You have a unique need so you have to develop your own process.
John
Project MVP