Trouble with win32com and MS Project

Discussion in 'Python' started by Felix Collins, Oct 20, 2005.

  1. 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
    Felix Collins, Oct 20, 2005
    #1
    1. Advertising

  2. Hi !


    The parameter (ResourceID=2) is problematic

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



    @-salutations

    Michel Claveau
    Do Re Mi chel La Si Do, Oct 20, 2005
    #2
    1. Advertising

  3. 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....
    Felix Collins, Oct 20, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hypo
    Replies:
    6
    Views:
    406
  2. Mike Margerum

    win32com and com Record types

    Mike Margerum, Aug 19, 2003, in forum: Python
    Replies:
    2
    Views:
    959
    Chuck Spears
    Aug 20, 2003
  3. Marc

    py2exe and win32com

    Marc, Oct 15, 2003, in forum: Python
    Replies:
    1
    Views:
    738
    Thomas Heller
    Oct 16, 2003
  4. Raaijmakers, Vincent (IndSys,GE Interlogix)

    Newbie in win32com: getters and setters

    Raaijmakers, Vincent (IndSys,GE Interlogix), Oct 23, 2003, in forum: Python
    Replies:
    0
    Views:
    269
    Raaijmakers, Vincent (IndSys,GE Interlogix)
    Oct 23, 2003
  5. Chris Curvey

    win32com and apache and permissions

    Chris Curvey, May 14, 2005, in forum: Python
    Replies:
    1
    Views:
    312
    Chris Curvey
    May 14, 2005
Loading...

Share This Page