R
Robert
Hello,
In order to test Resource custom fields, I tried to write a VBA macro that
would transfer data into Resource[Text2] field:
But it doesn't work when a resource is assigned to another project : "Other
projects and commitments".
What would be an efficient test to avoid the error on "Other projects and
commitments"?
Thanks for your help.
What I have tried (without success):
Sub ResourceText2Field()
Dim oRes As Resource
Dim Ass As Assignment
Dim i As Integer, Vide As Boolean
'On Error Resume Next
For Each oRes In ActiveProject.Resources
i = 0
For Each Ass In oRes.Assignments
i = i + 1
'First lap...
If i = 1 Then
'If we are on an assignment row: "Autres projets et
engagements": Ass.TaskName = "Autres projets et engagements"
If oRes.Assignments(i).TaskID = -1 Then
Vide = True
GoTo skip
End If
oRes.Text2 = oRes.Assignments(i).TaskID
Else
'Attention: Assignment.Text2 is that one which appears in
Task Usage
If Vide = True Then
oRes.Text2 = oRes.Assignments(i).TaskID
Else
oRes.Text2 = oRes.Text2 & " ; " &
oRes.Assignments(i).TaskID
End If
skip:
End If
Next Ass
Next oRes
End Sub
In order to test Resource custom fields, I tried to write a VBA macro that
would transfer data into Resource[Text2] field:
But it doesn't work when a resource is assigned to another project : "Other
projects and commitments".
What would be an efficient test to avoid the error on "Other projects and
commitments"?
Thanks for your help.
What I have tried (without success):
Sub ResourceText2Field()
Dim oRes As Resource
Dim Ass As Assignment
Dim i As Integer, Vide As Boolean
'On Error Resume Next
For Each oRes In ActiveProject.Resources
i = 0
For Each Ass In oRes.Assignments
i = i + 1
'First lap...
If i = 1 Then
'If we are on an assignment row: "Autres projets et
engagements": Ass.TaskName = "Autres projets et engagements"
If oRes.Assignments(i).TaskID = -1 Then
Vide = True
GoTo skip
End If
oRes.Text2 = oRes.Assignments(i).TaskID
Else
'Attention: Assignment.Text2 is that one which appears in
Task Usage
If Vide = True Then
oRes.Text2 = oRes.Assignments(i).TaskID
Else
oRes.Text2 = oRes.Text2 & " ; " &
oRes.Assignments(i).TaskID
End If
skip:
End If
Next Ass
Next oRes
End Sub