edmacey
asked on
projectwrapper and inspectors- help with Outlook VBA
I am trying to get the inspectors event to look for two different activities, is this the correct code
Option Explicit
Dim WithEvents inspectors As inspectors
Dim WithEvents project As TaskItem
Dim root As folder
Private Sub Application_Startup()
Set inspectors = Application.inspectors
Set root = Application.Session.Folder s("Busines s Contact Manager")
Set project = root.Folders("Business Projects").items(1)
End Sub
Private Sub inspectors_NewInspector(By Val inspector As inspector)
If inspector.CurrentItem.Clas s <> olTask Then Exit Sub
Dim oTaskItem As TaskItem
Set oTaskItem = inspector.CurrentItem
If oTaskItem.MessageClass <> "IPM.Task.BCM.Project" Then Return
Dim oProjectWrapper As New ProjectWrapper
oProjectWrapper.Init inspector
If oTaskItem.MessageClass <> "IPM.Task.BCM.ProjectTask" Then
Dim oTaskWrapper As New ProjectWrapper
oTaskWrapper.Init inspector
End Sub
I did have a second Return after Then from the ProjectTask bit but it threw an error.
Should my class modules be called ProjectWrapper and TaskWrapper or have I got it all a bit confused?
Thanks Ed.
Option Explicit
Dim WithEvents inspectors As inspectors
Dim WithEvents project As TaskItem
Dim root As folder
Private Sub Application_Startup()
Set inspectors = Application.inspectors
Set root = Application.Session.Folder
Set project = root.Folders("Business Projects").items(1)
End Sub
Private Sub inspectors_NewInspector(By
If inspector.CurrentItem.Clas
Dim oTaskItem As TaskItem
Set oTaskItem = inspector.CurrentItem
If oTaskItem.MessageClass <> "IPM.Task.BCM.Project" Then Return
Dim oProjectWrapper As New ProjectWrapper
oProjectWrapper.Init inspector
If oTaskItem.MessageClass <> "IPM.Task.BCM.ProjectTask"
Dim oTaskWrapper As New ProjectWrapper
oTaskWrapper.Init inspector
End Sub
I did have a second Return after Then from the ProjectTask bit but it threw an error.
Should my class modules be called ProjectWrapper and TaskWrapper or have I got it all a bit confused?
Thanks Ed.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER