Summary Tasks

E

Esperanza

Hello, I had a question that Im not too sure on how complicated it is.
I have modified the timesheet macro and this is the code I have:

'export informatin to excel
For Each R In Proj.Resources
xlR.Range("B1") = R.Name
xlR.Range("B1").Font.Bold = True
xlR.Range("B1").Font.ColorIndex = 3
Set xlR = xlR.Offset(1, 0)
'Export Assignment details
For Each A In R.Assignments
'filter assignments that are not complete and scheduled to
start within the next two weeks

If A.RemainingWork <> 0 Then
If A.Start <= (Proj.StatusDate + 14) Then
If A.TaskSummaryName <> currentsummary Then
xlR.Range("B1") = A.TaskSummaryName
xlR.Range("B1").Font.Bold = True
Set xlR = xlR.Offset(1, 0)
End If
currentsummary = A.TaskSummaryName
xlR.Range("a1:K1") = Array(A.TaskID, A.TaskName,
Format(A.ActualStart, "Short Date"), , Format(A.RemainingWork /
divideby, "0.0"), A.ActualFinish, , Format(A.Start, "Short Date"),
Format(A.Finish, "Short Date"), Format(A.Work / divideby, "0.0"),
Format(A.ActualWork / divideby, "0.0"))
Set xlR = xlR.Offset(1, 0)
End If
End If
Next
Set xlR = xlR.Offset(1, 0)
currentsummary = ""


This code will export to Excel all work that is not yet completed and
work that will start in the next two weeks. You can see that for each
assignment I have A.TaskSummaryName. The problem is that I want this
level of the summary and also the summary of the next level above
this. For instance I could have
1. Steps to do so and so (summary)
2. substeps to do...(summary)
3. detailed tasks (task)

So with what I have I can get 2 and 3 but i want to be able to get to
1. I hope I have not made this confusing. Thanks for any help on this.
 
J

JackD

You have to find the parent task of the task which the assignment is for.
To do this, you need to move from the assignment to a task and then you can
easily find the parent, and the parent of the parent and so on.



Sub fields()
Dim a As Assignment
Dim tid As Integer
Dim t, tParent As Task

'for an example we use the first assignment of the first resource in the
project
Set a = ActiveProject.resources(1).Assignments(1)

'get the taskID for the assignment from the assignment
tid = a.TaskID

'get the task that the TaskID refers to.
Set t = ActiveProject.Tasks(tid)

'get the parent task of that task
Set tParent = t.OutlineParent

'
MsgBox tParent.Name
End Sub

You still need to handle the cases when there is no parent, but you should
be able to handle that with a simple test.

-Jack
 

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