Option Explicit
Private Sub butOK_Click()
'validate inputs and create task
Dim itmTask As Outlook.TaskItem
Dim oObj As Object
If Len(Trim$(txtSubject)) = 0 Then
MsgBox "Tasks must have a Subject"
Exit Sub
End If
If dtStartDate > dtDueDate Then
MsgBox "Due Date must be later " & _
"than Start Date"
Exit Sub
End If
Set itmTask = _
g_COutlook.OutlookApp.CreateItem _
(olTaskItem)
With itmTask
.Subject = txtSubject
.DueDate = dtDueDate
.StartDate = dtStartDate
.Importance = olImportanceNormal
.Body = txtBody
.Save
End With
Set itmTask = Nothing
ClearForm
Me.Hide
End Sub
Private Sub butCancel_Click()
ClearForm
Me.Hide
End Sub
Private Sub txtStartDate_Enter()
txtStartDate.SelStart = 0
txtStartDate.SelLength = Len(txtStartDate)
End Sub
Private Sub UserForm_Activate()
ClearForm
Me.Caption = g_kFormCaption
End Sub
Private Sub ClearForm()
txtSubject = "
dtDueDate = date + 1
dtStartDate = Date
txtBody = "
txtSubject.SetFocus
End Sub
|