Moving a Task

E

Evan S. Dictor

My question is completely different from the other Moving Task question, so I
started a new thread instead of continuing that one.

I am working on a Project add-in DLL written in VB6. A user selects an
option that checks external data and determines that a task in the project is
in the wrong place (generally has the wrong parent task). Is there any way
for me to move that task and all it's children to the new parent?

task.parent is Read Only, so that doens't work. The only way I've found so
far is to insert a new blank task in the correct parent, copy all the fields
over, and then delete the task in the wrong parent. Recursion handles
anything below that, but the whole thing just seems very ugly to me.

I also tried EditCut and EditPaste, but the EditPaste gave me a "The method
is not available in this situation." error, and the clipboard didn't seem to
have the correct task (or any task for that matter) anyway. I also don't like
the idea of blowing away the clipboard.

Is there a better way?

Thanks,
Evan S. Dictor
 
J

Jan De Messemaeker

Hi,

EditCut and EditPaste are by far the easiest way to handle this.
Bear in mind though, that when you cut say 20 tasks, all taska after that
are renumbered and the ID you tried to select before pasting may well be
larger than the number of tasks after the cut.
If not for that, cut/paste works like a charm.
HTH
 
E

Evan S. Dictor

When I try to use EditCut and EditPaste I get "The method is not available in
this situation." Also, it doesn't seem like the Cut actually cut a task,
since I can't paste it by hand afterwards.

Evan S. Dictor
 
J

Jan De Messemaeker

Hi,

Did you select a task before cutting?
Did you select a task before pasting?
It does work, no good to despair, we should look for your little error.
HTH
 
E

Evan S. Dictor

Here is the code that I am using. Doesn't appear to be cutting or pasting:

Application.SelectRow ActiveProject.Tasks(iCtr2).Id
Application.EditCut
Application.SelectRow oTask.Id + 1
Application.EditPaste

Evan S. Dictor
 
G

Gary L. Chefetz [MVP]

Evan:

In case you're working in Project Server, I wanted to throw in a caution
about using these methods, which, I suspect, can produce duplicate key data
in the Project Server database.
 
J

Jan De Messemaeker

Hi,

Gotcha!
In teh selectrow method, the second parameter, rowrelative, is true by
default so the rowid you select is the one active at the time of selection
PLUS the ID in your statement so the probability that you select and try to
cut/paste something beyongd the final task is real.

Selectrow row:=thenumber, rowrelative:=false
will solve your problem.
HTH
 

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