M
Mark
I am getting a strange result using this method and don't know whay and need
some help if any of you out there can.
I am using a VBA program to automatically asign resources to a task. The
line of code is shown below:
Call
prjProjectToSearch.Tasks(intTaskId).Assignments.Add(prjProjectToSearch.Tasks(intTaskId).ID, prjProjectToSearch.Resources(lngTemp).UniqueID, intNoOfPeople)
I basically have a loop a round this statement so I can add multiple
resources. The weird thing I find is that if I add more than one resource all
with units of 100%, when the program has finished running and I check the
tasks......the units sometimes jump to massive percentages all by themselves.
And I don't know why.
Project just seems to reassign it by itself. I do not have levelling on so
don't know why it does it. I will put the full method below so you can see
what I am doing in full.
Private Sub AssignResource(ByVal prjProjectToSearch As Project, ByVal
strResourceName As String, ByVal intTaskId As Integer, ByVal
dblPercetageOfWork As Double)
Dim lngTemp As Long
Dim intNoOfPeople As Integer
Dim longPeriodDays As Double
'Is there any period or work
'lngPeriodDays = prjProjectToSearch.Tasks(intTaskId).Finish -
prjProjectToSearch.Tasks(intTaskId).Start
If (prjProjectToSearch.Tasks(intTaskId).Duration > 0 And
prjProjectToSearch.Tasks(intTaskId).Work > 0) Then
'Calculate number of people
intNoOfPeople =
CalculateWorkPercentage(prjProjectToSearch.Tasks(intTaskId).Duration,
prjProjectToSearch.Tasks(intTaskId).Work) * dblPercetageOfWork
'Try to find resource and add if found
For lngTemp = 1 To prjProjectToSearch.Resources.Count
If Not prjProjectToSearch.Resources(lngTemp) Is Nothing Then
If prjProjectToSearch.Resources(lngTemp).name =
strResourceName Then
Call
prjProjectToSearch.Tasks(intTaskId).Assignments.Add(prjProjectToSearch.Tasks(intTaskId).ID, prjProjectToSearch.Resources(lngTemp).UniqueID, intNoOfPeople)
Exit For
End If
End If
Next lngTemp
End If
End Sub
some help if any of you out there can.
I am using a VBA program to automatically asign resources to a task. The
line of code is shown below:
Call
prjProjectToSearch.Tasks(intTaskId).Assignments.Add(prjProjectToSearch.Tasks(intTaskId).ID, prjProjectToSearch.Resources(lngTemp).UniqueID, intNoOfPeople)
I basically have a loop a round this statement so I can add multiple
resources. The weird thing I find is that if I add more than one resource all
with units of 100%, when the program has finished running and I check the
tasks......the units sometimes jump to massive percentages all by themselves.
And I don't know why.
Project just seems to reassign it by itself. I do not have levelling on so
don't know why it does it. I will put the full method below so you can see
what I am doing in full.
Private Sub AssignResource(ByVal prjProjectToSearch As Project, ByVal
strResourceName As String, ByVal intTaskId As Integer, ByVal
dblPercetageOfWork As Double)
Dim lngTemp As Long
Dim intNoOfPeople As Integer
Dim longPeriodDays As Double
'Is there any period or work
'lngPeriodDays = prjProjectToSearch.Tasks(intTaskId).Finish -
prjProjectToSearch.Tasks(intTaskId).Start
If (prjProjectToSearch.Tasks(intTaskId).Duration > 0 And
prjProjectToSearch.Tasks(intTaskId).Work > 0) Then
'Calculate number of people
intNoOfPeople =
CalculateWorkPercentage(prjProjectToSearch.Tasks(intTaskId).Duration,
prjProjectToSearch.Tasks(intTaskId).Work) * dblPercetageOfWork
'Try to find resource and add if found
For lngTemp = 1 To prjProjectToSearch.Resources.Count
If Not prjProjectToSearch.Resources(lngTemp) Is Nothing Then
If prjProjectToSearch.Resources(lngTemp).name =
strResourceName Then
Call
prjProjectToSearch.Tasks(intTaskId).Assignments.Add(prjProjectToSearch.Tasks(intTaskId).ID, prjProjectToSearch.Resources(lngTemp).UniqueID, intNoOfPeople)
Exit For
End If
End If
Next lngTemp
End If
End Sub