Trouble with win32com and MS Project

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Felix Collins

    #1

    Trouble with win32com and MS Project

    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.T asks(1).Assignm ents.Add ResourceID:=212 "

    My code fragment for Python...

    proj.Tasks(3).A ssignments.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\\Microsof t
    Office\\OFFICE1 1\\VBAPJ.CHM', 131074, -2146827187), None)


    Anyone got any ideas about how to attack this?

    Cheers,
    Felix
  • Do Re Mi chel La Si Do

    #2
    Re: Trouble with win32com and MS Project

    Hi !


    The parameter (ResourceID=2) is problematic

    Try :
    proj.Tasks(3).A ssignments.Add( 2)



    @-salutations

    Michel Claveau



    Comment

    • Felix Collins

      #3
      Re: Trouble with win32com and MS Project

      Felix Collins wrote:[color=blue]
      > 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.T asks(1).Assignm ents.Add ResourceID:=212 "
      >
      > My code fragment for Python...
      >
      > proj.Tasks(3).A ssignments.Add( ResourceID=2)[/color]

      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).A ssignments.Add( TaskID= 3,ResourceID=2)

      incidently this also works...

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

      which does seems a bit strange....

      Comment

      Working...