J
jennifer.lyon
Not sure what I am doing wrong (I realize the overall code is not the
cleanest in the world...esp. in terms of how I am accessing
"ActiveProject.."
Anyways, I am getting a Run-Time Error 1101 "The Argument Value is not
Valid".
What I'm doing is a simple scan of the list of resources for each task
in a project and building a formatted text string of the resources that
includes the resource UID, e.g. "[5]John.Jones, [34]James.Doe,
[234]Jim.Smith"
Then I want to assign that formatted string to the Text11 field within
the Tasks object, and the code is dying on the assignment statement.
Immediately before the attempt to perform the assignment, the
debug.print statement shows that the variable for the formatted string
does indeed have data in it.
The offending line of code is...
ActiveProject.Tasks(CurrRow).Text11 = FormatResourceNames
The overall code segment is: (mind the wrapping from google)
Sub CopyResourceNamestoText11()
Dim CurrRow As Long
Dim NumTasks As Long, NumResources As Long
Dim CurrResourceName As String, FormatResourceNames As String,
TempString As String, CurrResource As String
Dim CurrResourceUID As String
NumTasks = ActiveProject.NumberOfTasks
For CurrRow = 1 To NumTasks
NumResources = ActiveProject.Tasks(CurrRow).Resources.Count
If NumResources > 0 Then 'Theres at least 1 resource assigned
to the current task
Debug.Print "This Task has " & NumResources & " Resources
assigned."
FormatResourceNames = ""
For ICount = 1 To NumResources
CurrResourceName =
ActiveProject.Tasks(CurrRow).Resources(ICount).Name
CurrResourceUID =
ActiveProject.Resources(CurrResourceName).UniqueID
FormatResourceNames = FormatResourceNames & "[" &
CurrResourceUID & "]" & CurrResourceName & ", "
Next ICount
Debug.Print FormatResourceNames
ActiveProject.Tasks(CurrRow).Text11 = FormatResourceNames
End If
Next CurrRow
End Sub
cleanest in the world...esp. in terms of how I am accessing
"ActiveProject.."
Anyways, I am getting a Run-Time Error 1101 "The Argument Value is not
Valid".
What I'm doing is a simple scan of the list of resources for each task
in a project and building a formatted text string of the resources that
includes the resource UID, e.g. "[5]John.Jones, [34]James.Doe,
[234]Jim.Smith"
Then I want to assign that formatted string to the Text11 field within
the Tasks object, and the code is dying on the assignment statement.
Immediately before the attempt to perform the assignment, the
debug.print statement shows that the variable for the formatted string
does indeed have data in it.
The offending line of code is...
ActiveProject.Tasks(CurrRow).Text11 = FormatResourceNames
The overall code segment is: (mind the wrapping from google)
Sub CopyResourceNamestoText11()
Dim CurrRow As Long
Dim NumTasks As Long, NumResources As Long
Dim CurrResourceName As String, FormatResourceNames As String,
TempString As String, CurrResource As String
Dim CurrResourceUID As String
NumTasks = ActiveProject.NumberOfTasks
For CurrRow = 1 To NumTasks
NumResources = ActiveProject.Tasks(CurrRow).Resources.Count
If NumResources > 0 Then 'Theres at least 1 resource assigned
to the current task
Debug.Print "This Task has " & NumResources & " Resources
assigned."
FormatResourceNames = ""
For ICount = 1 To NumResources
CurrResourceName =
ActiveProject.Tasks(CurrRow).Resources(ICount).Name
CurrResourceUID =
ActiveProject.Resources(CurrResourceName).UniqueID
FormatResourceNames = FormatResourceNames & "[" &
CurrResourceUID & "]" & CurrResourceName & ", "
Next ICount
Debug.Print FormatResourceNames
ActiveProject.Tasks(CurrRow).Text11 = FormatResourceNames
End If
Next CurrRow
End Sub