C
Chris
Hey All --
I'm trying to create a Project 2003 macro to show a list of tasks for the
ActiveProject in a form... I'm FOR EACH'ing each task into an array but the
values don't seem to accumulate - I only get 1 task in the Array.
The code below is looping correctly; I can MsgBox each Task fine... just
something wrong with my code for the array:
As said, only one task seems to populate in the array (I assume it's
overwriting the value each time) but if I put "MsgBox T.Name" in the loop, it
displays each value consecutively...
What am I missing? Any help that can be offered to this VBA newbie would be
appreciated!!!
Thanks
I'm trying to create a Project 2003 macro to show a list of tasks for the
ActiveProject in a form... I'm FOR EACH'ing each task into an array but the
values don't seem to accumulate - I only get 1 task in the Array.
The code below is looping correctly; I can MsgBox each Task fine... just
something wrong with my code for the array:
Code:
Private Sub UserForm_Initialize()
Dim T As Task
Dim Ts As Tasks
Dim strTasksArray() As String
Dim intCount As Integer
Dim Total As Integer
Set Ts = ActiveProject.Tasks
intCount = 0
ReDim Preserve strTasksArray(intCount)
For Each T In Ts
On Error Resume Next
If Not (T Is Nothing) Then
strTasksArray(intCount) = T.Name
intCount = intCount + 1
End If
Next T
lstTasks.List() = strTasksArray
End Sub
As said, only one task seems to populate in the array (I assume it's
overwriting the value each time) but if I put "MsgBox T.Name" in the loop, it
displays each value consecutively...
What am I missing? Any help that can be offered to this VBA newbie would be
appreciated!!!
Thanks