Assigning resources to all tasks

O

Oskari Juslin

Hi everybody!

I made a procedure to assign a Dummy resources to all
tasks of the project, but it can't handle e.g. situations
where tasks are copied and pasted. Can anybody help?

Here how it is done now:

Private Sub AddDummies()

Dim ID As Long, Task As Task
Dim R As Resource, i As Integer, UnikkoID

Set R = ActiveProject.Resources.Add(Name:="Dummy")

For Each Task In ActiveProject.Tasks
If Task.Name <> "" Then
If ActiveProject.Tasks(Task).Summary Then
Else
R.Assignments.Add TaskID:=(Task)
End If
End If
Next

End Sub
 
J

Jan De Messemaeker

Hi Oskari,

Before even replying to your question, soem important advice.

Your test task.name="" won't do
When you try to handle an empty line the task will come up as Nothing and
task.name will cause an abend because task being nothing, it doesn't have
any properties.

So after "for each task..." the test to ALWAYS perform is
If not task is Nothing then


Now to your question.
I'm sorry to say that I do not understand it.

When you say for each task, you will handle each and every task, even if it
has been moved.
What exactly is the problem?


--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
Project Management Consultancy
Prom+ade BVBA
32-495-300 620
 
O

Oskari Juslin

Thank you Jan for your advice. I'll try to specify the
problem:

My aim is to assign a Dummy-resource to all tasks of the
project plan, except the summary tasks. The way I assign
the resource works just fine aslong the project plan is
created without further editing, e.g new tasks are not
created by copying old ones ect.

The problem is that my procedure causes a "Runtime-error
1101 The argument value is not valid" error. And this
happens when I have edited the MSP plan by
copying/cutting and pasting tasks in the plan.

When the error message appears, the following line is
yellow

Line: If ActiveProject.Tasks(Task).Summary Then

where the value of Task has been a greater number then
there are tasks in the projec plan.

Hope this makes clear what the problem is.
 
O

Oskari Juslin

Hi Jan,
it seems to work now. Thank you very much for your help.
Have a nice weekend :eek:)

BR Osku
 

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