Sub oItem_PropertyChange(ByVal Name As String) doesn't fire

V

vonclausowitz

Hello,

I have a problem with my Propertychange function which won't fire when
a field has been changed.

Public WithEvents oItem As Outlook.Items

Sub oItem_PropertyChange(ByVal Name As String)

Select Case Name
Case "Role"
If CDate(oItem.Role) = Date - 1 Or CDate(oItem.Role) = Date
And oItem.DueDate = Date Then
MsgBox "Ok, the Role date changed!"
End If
Case Else
MsgBox "ELSE...nothing really"
End Select

End Sub

Marco
 
S

Sue Mosher [MVP-Outlook]

How are you instantiating the oItem object?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
V

vonclausowitz

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top