Trouble with win32com and MS Project

F

Felix Collins

Hi,

I'm trying to assign a resource to a task in MS Project by using the
example from MSDN for VB...


"Use the Add method to add an Assignment object to the Assignments
collection. The following example adds a resource identified by the
number of 212 as a new assignment for the specified task.

ActiveProject.Tasks(1).Assignments.Add ResourceID:=212"

My code fragment for Python...

proj.Tasks(3).Assignments.Add(ResourceID=2)

but this doesn't work. I get...

Error (-2147352567, 'Exception occurred.', (0, None, 'The argument value
is not valid.', 'D:\\Program Files\\Microsoft
Office\\OFFICE11\\VBAPJ.CHM', 131074, -2146827187), None)


Anyone got any ideas about how to attack this?

Cheers,
Felix
 
D

Do Re Mi chel La Si Do

Hi !


The parameter (ResourceID=2) is problematic

Try :
proj.Tasks(3).Assignments.Add(2)



@-salutations

Michel Claveau
 
F

Felix Collins

Felix said:
Hi,

I'm trying to assign a resource to a task in MS Project by using the
example from MSDN for VB...


"Use the Add method to add an Assignment object to the Assignments
collection. The following example adds a resource identified by the
number of 212 as a new assignment for the specified task.

ActiveProject.Tasks(1).Assignments.Add ResourceID:=212"

My code fragment for Python...

proj.Tasks(3).Assignments.Add(ResourceID=2)

I managed to get this to work by providing the TaskID which is supposed
to be an optional argument. I wonder if the win32com wrapper is
stuffing this up. Is late binding responsible perhaps?

So the code that works is...

proj.Tasks(3).Assignments.Add(TaskID= 3,ResourceID=2)

incidently this also works...

proj.Tasks(3).Assignments.Add(TaskID= 5,ResourceID=2)

which does seems a bit strange....
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top