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.

2
  • It says to use TimeScaleValues (index), where index is the index number of the timescaled data item, to return a single TimeScaleValue object. learn.microsoft.com/en-us/office/vba/api/… Commented Jul 4, 2019 at 11:49
  • Thanks, I didn't notice it and finally reached the solution for it. I'll paste it down below. Commented Jul 5, 2019 at 4:21

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Consider marking your answer as accepted so that this question no longer shows in the unanswered queue.
Where do the variables pjAssignmentTimescaledWork and pjTimescaleDays come from?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.