I create tasks through code since they’re extremely repetitive. I would like to share them between myself and another worker, and let us both be able to update/complete them. My code is below, can anyone give me some advice?
Private Sub btnCreate_Click()
Const intNumTasks As Integer = 10
Const strTaskSubj As String = “Graduation day;Complete grad package; Copies of orders to travel; Pull SRBs for grad packages; Medical/Dental Letter to Kirk; ” & _
“Orders Brief; Schedule Overseas Physicals; Create Orders and Medical/Dental Record letter; ” & _
“Book port calls; Check for web orders”
Const strDaysPrior As String = “0;2; 6;7;7;7 ; 14; 20; 20; 30”
Dim itmTask As TaskItem
Dim dateDue As Date
Dim intC As Integer
Dim x As String
Dim y As String
x = InputBox(“Who do you want to assign the task to? Type their user name in the box below. Example: hazlettjm”, “Assign to who?”)
y = InputBox(“Who else do you want to assign the task to? Type their user name in the box below. Example: hazlettjm”, “Assign to who?”)
If Not IsDate(txtGradDate) Then
txtGradDate = “”
Exit Sub
End If
For intC = 0 To intNumTasks – 1
Set itmTask = Outlook.CreateItem(olTaskItem)
With itmTask
dateDue = DateAdd(“D”, -CInt(Split(strDaysPrior, “;”, -1, vbTextCompare)(intC)), txtGradDate)
If Weekday(dateDue) = 1 Then dateDue = dateDue – 2 ‘ move Sun to preceding Fri
If Weekday(dateDue) = 7 Then dateDue = dateDue – 1 ‘ move Sat to preceding Fri
.DueDate = dateDue ‘ due date, not reminder date
.Subject = txtClassName & ” – ” & Split(strTaskSubj, “;”, -1, vbTextCompare)(intC)
.Categories = txtClassName & “Grad Class Tasks”
.Body = “Reminder to complete”
.ReminderTime = DateAdd(“D”, -1, dateDue) + 8 / 24 ‘ 8: 00 AM day before due
.Assign
If x = “” Then
‘do nothing
Else
.Recipients.Add x
End If
If y = “” Then
‘do nothing
Else
.Recipients.Add y
End If
.Save
If x = “hazlettjm” Then
‘do nothing
Else
.Send
End If
End With
Next intC
Unload Me
End Sub