Public Sub Initialize_handler()
Set oTasks =
Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderTasks).Items
Set oExplorer = Application.ActiveExplorer
Set oApplication = Outlook.Application
End Sub
Private Sub oExplorer_SelectionChange()
Dim strCurrentUser As String
Dim nmsUser As Outlook.NameSpace
Set nmsUser = oApplication.GetNamespace("MAPI")
strCurrentUser = nmsUser.CurrentUser
If oExplorer.CurrentFolder.Name = "Taken" Then
If strCurrentUser = "þ" Then
If oExplorer.Selection.Count <> 0 Then
Set oTask = oExplorer.Selection(1)
End If
End If
End If
' If oExplorer.CurrentFolder.DefaultItemType = olTaskItem Then
' Set oTask = oExplorer.Selection(1)
' End If
End Sub
Private Sub oTasks_ItemChange(ByVal item As Object)
Dim Response As Integer
Dim oTask As TaskItem
Dim NS As NameSpace
Dim newTaskFolder As MAPIFolder
Dim strCurrentUser As String
Dim nmsUser As Outlook.NameSpace
Set nmsUser = oApplication.GetNamespace("MAPI")
strCurrentUser = nmsUser.CurrentUser
Set NS = Application.GetNamespace("MAPI")
Set newTaskFolder =
NS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks).Folders("Taken
Oud")
Set oTask = item
If oTask.Status = 2 Then '2 = Completed
'MsgBox "Task was completed " & oTask.Subject
oTask.UserProperties("Updater") = strCurrentUser & " " &
Date
oTask.Save
oTask.Move newTaskFolder
End If
'als de role datum is vandaag of gister en de taak is voor
vandaag dan...
If CDate(oTask.Role) = Date - 1 Or CDate(oTask.Role) = Date And
oTask.DueDate = Date Then
'pas het veld updater aan...
oTask.UserProperties("Updater") = strCurrentUser & " " &
Date
oTask.Save
'wil je de taak afvinken?
Response = MsgBox("Would you like to Complete '" &
oTask.Subject & "'?", vbYesNo, "Continue")
If Response = 6 Then
oTask.Status = olTaskComplete
oTask.Move newTaskFolder
End If
End If
End Sub
Sub oTask_PropertyChange(ByVal Name As String)
Select Case Name
Case "Role"
If CDate(oTask.Role) = Date - 1 Or CDate(oTask.Role) = Date
And oTask.DueDate = Date Then
MsgBox "Ok, the Role date changed!"
End If
Case "DueDate"
Case Else
MsgBox "ELSE...nothing really"
End Select
End Sub
This is all my code. The way I describe it the PropertyChange does get
fired but What should I use, the PropertyChange or the ItemChange.
I want to catch someone changing the Role field in an item.
and after that update the User defined field Updater, as you can see in
the code.
Regards
Marco