how to change a task's parent

J

Joy

I wish to change task's summary task. like, I have many tasks in different
summary tasks
I will choose some task, and change their summary to the same summary task,
say 'deleted', can I do that????
I trie setfield, or tsk.parent="deleted"
seems does not work....
many thanks!!
 
J

John

Joy said:
I wish to change task's summary task. like, I have many tasks in different
summary tasks
I will choose some task, and change their summary to the same summary task,
say 'deleted', can I do that????
I trie setfield, or tsk.parent="deleted"
seems does not work....
many thanks!!

Joy,
I'm sorry but you post doesn't make much sense, (i.e. "...choose some
task, and change their summary to the same summary task...").

What are you really trying to do in terms of your end goal?

John
Project MVP
 
J

Joy

sorry,

we need a macro
when user delete a task in the ms project, the task is acturally moved to
another place, that is, the end of the project file. we first create a
summary task at the end of the project file named 'Deleted tasks', and then
when you delete a task, the task will be moved to the summary task.

I tried serveral means,but seems have various issues:(

I sought for help these days online, but still could not get it done.

I tried to change a task's parent, but it does not work, either, it just
change the name of the parent, but does not move the task into the summary
task 'Deleted tasks'.

Now, I created a summary task at the end of file named 'Deleted tasks'. I
want to copy task which is to be deleted, say A to another task, say B (use B
to record all infor of A), and then put B in 'Deleted tasks', and then delete
A. Now, I can put a new task in 'Deleted tasks'. The task has the same name
with the one to be deleted. But, other fields are wrong. other fields are not
set acturally.

Another issue is that the task to be deleted can not be deleted,
tsk.Delete does not work well, is there any other means to delete a task???

many thanks.
 
J

Jack Dahlgren MVP

I think you will have to cut and paste the task.
I thought there was a method to move tasks, but I don't seem to find it
anywhere.
You could also do it using a sort and renumber combined with an indent...
give it some identifying code where each task has it's task id except
the one you want to move (make it a large number)
sort by that code so it is at the end with the task renumbering on. This
will place the task at the end of the file. Outdent it as far as possible,
then indent once.

-Jack Dahlgren
 
J

Joy

thank you

I tried copy and paste, it works.
then I think I need to delete the task, but I cannot do it
if I use tsk.Delete, it will paste 10 copies of the task at the end, which
should be only 1.



my code is as follows:


Public WithEvents App As Application

Private Sub app_ProjectBeforeTaskDelete(ByVal tsk As task, Cancel As Boolean)

On Error Resume Next

If tsk Is Nothing Then
Exit Sub

Else


'clear dependencies
For Each dep In tsk.TaskDependencies
dep.Delete
Next dep

'copy fields to a row in summary task "Removed Task"
nTsk = ActiveProject.Tasks.Add(tsk.Name)
With ActiveProject.Tasks(nTsk)
.Finish = tsk.Finish
.Start = tsk.Start
.Name = tsk.Name
.Critical = tsk.Critical
.Duration = tsk.Duration
.Predecessors = tsk.Predecessors
.ResourceNames = tsk.ResourceNames
.SetField pjTaskOutlineLevel, "2"
.SetField pjTaskRollup, "Yes"
End With

'message box
Cancel = True
MsgBox "Task has been moved to the end of file.", vbExclamation

'remove the task to be deleted

End If
On Error GoTo 0
End Sub

I tried not to comment Cancel = True, to use MS project's own delete to
delete task, then the task can be deleted, but fields other then 'Name'
cannot be set as the original one.

I will try your 2nd method, but I wish I could do it with this one

Thank you so much for your time!!!!
 

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