2

I am trying to use pywin32 Python Library to extract data from MSProject .mpp file to an excel file where I want my employees to register their work hour.

I can extract data from any field I want except the Task Usage Table where it shows for every day how many hours an assignment (a person X a task) has to be done (Work) and has been done (Actual Work) and allows users to fill out the number of hours.

Image of the Task Usage Table

It seems that there is an Object for it if the case is VBA Programming, called TimeScaleValue object (Project) | Microsoft Docs

While it seems there is no similar attribute under Task object in pywin32. Are there any pieces of advice? Thanks a lot!

import win32com
...
Tasks_collection=ActiveProject.Tasks
for t in Tasks_collection:
   for r in t.Assignments:
        TSV_collection = r.TimeScaleValue('06/01/2019','08/01/2019')
...

Command Line gave me a message: AttributeError: win32com.gen_py.Microsoft Project . Object Library.Assignment instance object has no attribute 'TimeScaleValue'

Are there any pieces of advice? Thanks a lot.

Tim
  • 59
  • 5
  • It says to use `TimeScaleValues (index)`, where index is the index number of the timescaled data item, to return a single `TimeScaleValue` object. https://learn.microsoft.com/en-us/office/vba/api/project.timescalevalues – LuisTavares Jul 04 '19 at 11:49
  • Thanks, I didn't notice it and finally reached the solution for it. I'll paste it down below. – Tim Jul 05 '19 at 04:21

1 Answers1

1

Here is how I dealt with it. For everyone who needs the solution.

Tasks_collection=ActiveProject.Tasks
for t in Tasks_collection:
  for r in t.Assignments:
    #get a TimeScaleValues Collection
    TSV_collection=r.TimeScaleData('06/01/2019','08/01/2019',\
          pjAssignmentTimescaledWork,pjTimescaleDays)
    for tsv in TSV_collection:
      print(tsv.Value)

Assignment.TimeScaleData method (Project) | Microsoft Docs

TimeScaleValues object (Project) | Microsoft Docs

TimeScaleValue object (Project) | Microsoft Docs

Tim
  • 59
  • 5