How to export weekly actual hours to Excel with VBA

M

miao jie

now I try to export weekly efforts of each tasks to Excel file, when I use VBA to Create Task and Assignment object, but I can not find the weekly stage property in properties list
the format should to b
workweek1 WW2 WW3 WW
task1 40 40 36 10
task
task

anyone can help me out, thanks a lot
 
J

John

miao,
Your post talks about task assignment hours by week but your example
shows just task hours by week. The first code loop will give task hours
by week and the second will give task assignment hours by week.

Sub TaskHrsTimescale()
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
First = t.Start
Last = t.Finish
Set TaskHrs = t.TimeScaleData(First, Last, _
Type:=pjTaskTimescaledWork, _
timescaleunit:=pjTimescaleWeeks)
For i = 1 To TaskHrs.Count
joe = TaskHrs(i).Value / 60
[put the above value in Excel]
Next i
End If
Next t
End Sub

Sub AssHrsTimescale()
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
For Each A In t.Assignments
If Not A Is Nothing Then
First = A.Start
Last = A.Finish
Set TaskAss = A.TimeScaleData(First, Last, _
Type:=pjAssignmentTimescaledWork, _
timescaleunit:=pjTimescaleWeeks)
For i = 1 To TaskAss.Count
WeeklyHrs = TaskAss(i).Value / 60
[put the above value in Excel]
Next i
End If
Next A
End If
Next t
End Sub

Hope this helps.
John
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top