|
|
|
date: 2 Jan 2006 12:15:00 -0800,
group: microsoft.public.project.vba
back
Re: Link last task
OK, I got it to work with the following code. Is there an easier and quicker
way to do this?
Sub Last_Task_Link()
'If project is empty, alert the user and end the macro
If ActiveProject.Tasks.Count = 0 Then
MsgBox MSG_NO_TASKS, Buttons:=vbCritical + R_TO_L,
Title:=Application.Name
End
End If
Dim Temp As Long, Temp2 As Long
Dim R As Long, Names As String, FinishDate As Date, FinishID As String
For R = 1 To ActiveProject.Resources.Count
FinishID = 0
FinishDate = 0
Names = ActiveProject.Resources(R).Name
For Temp = 1 To ActiveProject.Tasks.Count
If Not ActiveProject.Tasks(Temp) Is Nothing Then
If StrComp(Names, ActiveProject.Tasks(Temp).ResourceNames, 1) =
0 Then
If DateValue(ActiveProject.Tasks(Temp).Finish) >=
DateValue(FinishDate) Then
FinishDate = ActiveProject.Tasks(Temp).Finish
FinishID = ActiveProject.Tasks(Temp).ID
End If
End If
End If
Next Temp
For Temp2 = 1 To ActiveProject.Tasks.Count
If Not ActiveProject.Tasks(Temp2) Is Nothing Then
If StrComp(Names, ActiveProject.Tasks(Temp2).Name, 1) = 0 Then
If Not FinishID = 0 Then
ActiveProject.Tasks(Temp2).Predecessors = FinishID
End If
End If
End If
Next Temp2
Next R
End Sub
- John
date: Mon, 2 Jan 2006 17:47:29 -0600
author: John john[nospam]terminalreality.com
Re: Link last task
Hi John,
Next time, please try posting on the developer newsgroup as this one's
closing down. Please see FAQ Item: 24. Project Newsgroups. FAQs,
companion products and other useful Project information can be seen at this
web address: http://project.mvps.org/faqs.htm
Mike Glen
Project MVP
John wrote:
> OK, I got it to work with the following code. Is there an easier and
> quicker way to do this?
>
> Sub Last_Task_Link()
>
> 'If project is empty, alert the user and end the macro
> If ActiveProject.Tasks.Count = 0 Then
> MsgBox MSG_NO_TASKS, Buttons:=vbCritical + R_TO_L,
> Title:=Application.Name
> End
> End If
>
>
> Dim Temp As Long, Temp2 As Long
> Dim R As Long, Names As String, FinishDate As Date, FinishID As String
>
> For R = 1 To ActiveProject.Resources.Count
> FinishID = 0
> FinishDate = 0
> Names = ActiveProject.Resources(R).Name
> For Temp = 1 To ActiveProject.Tasks.Count
> If Not ActiveProject.Tasks(Temp) Is Nothing Then
> If StrComp(Names, ActiveProject.Tasks(Temp).ResourceNames,
> 1) = 0 Then
> If DateValue(ActiveProject.Tasks(Temp).Finish) >=
> DateValue(FinishDate) Then
> FinishDate = ActiveProject.Tasks(Temp).Finish
> FinishID = ActiveProject.Tasks(Temp).ID
> End If
> End If
> End If
> Next Temp
> For Temp2 = 1 To ActiveProject.Tasks.Count
> If Not ActiveProject.Tasks(Temp2) Is Nothing Then
> If StrComp(Names, ActiveProject.Tasks(Temp2).Name, 1) = 0
> Then If Not FinishID = 0 Then
> ActiveProject.Tasks(Temp2).Predecessors = FinishID
> End If
> End If
> End If
> Next Temp2
> Next R
>
> End Sub
>
> - John
date: Tue, 3 Jan 2006 10:41:23 -0000
author: Mike Glen glenATmvps.org
|
|