P
Peter Rooney
I am writing a macro to go through every task in my plan and assign one of 19
calendars to it, depending on what it finds in the resource names field.
I'm doing this with a Case statement, which works fine in terms of
identifying the resource, I just can't assign the calendar.
Here's what I have so far:
Sub AssignCalendarsToTasks()
Dim TaskCounter As Integer
Dim ThisTasksResource As String
SelectSheet
For TaskCounter = 1 To ActiveSelection.Tasks.Count
ThisTasksResource = ActiveSelection.Tasks(TaskCounter).ResourceNames
MsgBox (ActiveSelection.Tasks(TaskCounter).ID & " - " &
ThisTasksResource)
Select Case ThisTasksResource
Case "Graham Tatton"
XX
activeselection.tasks(taskcounter).setfield(pjtaskcalendar,"01a-Graham
Tatton")
Case "Min Patel"
SetTaskField Field:="Task Calendar", Value:="01b-Min Patel",
AllSelectedTasks:=False
Case etc etc
Case Else
'MsgBox ("Somebody Else - " & ThisTasksResource)
SetTaskField Field:="Task Calendar", Value:="Standard",
AllSelectedTasks:=False
End Select
'Next
End Sub
It's the line beginning with XX that's giving me trouble.
"O1a-Graham Tatton" is the name of the calendar I want to apply if the first
case statement is met.
The code in the Case for "Min Patel" works, but only if the task row is
physically selected, which I don't want to have to do.
Can anyone help?
Thanks in advance
Pete
calendars to it, depending on what it finds in the resource names field.
I'm doing this with a Case statement, which works fine in terms of
identifying the resource, I just can't assign the calendar.
Here's what I have so far:
Sub AssignCalendarsToTasks()
Dim TaskCounter As Integer
Dim ThisTasksResource As String
SelectSheet
For TaskCounter = 1 To ActiveSelection.Tasks.Count
ThisTasksResource = ActiveSelection.Tasks(TaskCounter).ResourceNames
MsgBox (ActiveSelection.Tasks(TaskCounter).ID & " - " &
ThisTasksResource)
Select Case ThisTasksResource
Case "Graham Tatton"
XX
activeselection.tasks(taskcounter).setfield(pjtaskcalendar,"01a-Graham
Tatton")
Case "Min Patel"
SetTaskField Field:="Task Calendar", Value:="01b-Min Patel",
AllSelectedTasks:=False
Case etc etc
Case Else
'MsgBox ("Somebody Else - " & ThisTasksResource)
SetTaskField Field:="Task Calendar", Value:="Standard",
AllSelectedTasks:=False
End Select
'Next
End Sub
It's the line beginning with XX that's giving me trouble.
"O1a-Graham Tatton" is the name of the calendar I want to apply if the first
case statement is met.
The code in the Case for "Min Patel" works, but only if the task row is
physically selected, which I don't want to have to do.
Can anyone help?
Thanks in advance
Pete