Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Trouble with win32com and MS Project

Reply
Thread Tools

Trouble with win32com and MS Project

 
 
Felix Collins
Guest
Posts: n/a
 
      10-20-2005
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
 
Reply With Quote
 
 
 
 
Do Re Mi chel La Si Do
Guest
Posts: n/a
 
      10-20-2005
Hi !


The parameter (ResourceID=2) is problematic

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



@-salutations

Michel Claveau



 
Reply With Quote
 
 
 
 
Felix Collins
Guest
Posts: n/a
 
      10-20-2005
Felix Collins wrote:
> 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....
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
win32com and apache and permissions Chris Curvey Python 1 05-14-2005 01:08 PM
win32com from linux and jpq question Peder Ydalus Python 2 11-19-2003 02:04 PM
Newbie in win32com: getters and setters Raaijmakers, Vincent (IndSys,GE Interlogix) Python 0 10-23-2003 09:57 PM
py2exe and win32com Marc Python 1 10-16-2003 07:25 AM
win32com and com Record types Mike Margerum Python 2 08-20-2003 02:56 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57