Roland Askew
Member
- Outlook version
- Outlook 2021 64 bit
- Email Account
- IMAP
Any help with this would be really appreciated.
I have set up a class module and have it monitoring the default task folder. The module intialize but the event does not ever fire.
The code is as follows: I am using Outlook 2021.
Public Sub Application_Startup()
Set FolderT = New clsFolderTask
End Sub
In the class module I have
Private WithEvents Items As Outlook.Items
Sub Class_Initialize()
Dim Ns As Outlook.Namespace
Dim TaskFolder As Outlook.MAPIFolder
Dim Destfolder As Outlook.MAPIFolder
Dim Items As Items
Dim objApp As Application
Dim objViews As Views
Dim objView As View
Set objApp = Outlook.Application
Set Ns = Application.GetNamespace("MAPI")
Set TaskFolder = Ns.GetDefaultFolder(olFolderTasks)
Set Destfolder = TaskFolder.Folders("Completed") ' Subfolder of the Task Folder
Set Items = TaskFolder.Items
'Applies view to select folder
Set objViews = TaskFolder.Views
Set objView = objViews.Item("Tasks")
objView.Apply
End Sub
Private Sub Items_ItemChange(ByVal Item As Object)
Dim Ns As Outlook.Namespace
Dim TaskFolder As Outlook.MAPIFolder
Dim Destfolder As Outlook.MAPIFolder
Set Ns = Application.GetNamespace("MAPI")
Set TaskFolder = Ns.GetDefaultFolder(olFolderTasks)
Set Destfolder = TaskFolder.Folders("Completed")
If TypeOf objItem Is Outlook.TaskItem Then
If objItem.Status = olTaskComplete Then
Item.Move Destfolder
MsgBox "Completed and moved to Completed Folder"
End If
End If
End Sub
Any thoughts as to what might need to be changed
Thanks
Roland
I have set up a class module and have it monitoring the default task folder. The module intialize but the event does not ever fire.
The code is as follows: I am using Outlook 2021.
Public Sub Application_Startup()
Set FolderT = New clsFolderTask
End Sub
In the class module I have
Private WithEvents Items As Outlook.Items
Sub Class_Initialize()
Dim Ns As Outlook.Namespace
Dim TaskFolder As Outlook.MAPIFolder
Dim Destfolder As Outlook.MAPIFolder
Dim Items As Items
Dim objApp As Application
Dim objViews As Views
Dim objView As View
Set objApp = Outlook.Application
Set Ns = Application.GetNamespace("MAPI")
Set TaskFolder = Ns.GetDefaultFolder(olFolderTasks)
Set Destfolder = TaskFolder.Folders("Completed") ' Subfolder of the Task Folder
Set Items = TaskFolder.Items
'Applies view to select folder
Set objViews = TaskFolder.Views
Set objView = objViews.Item("Tasks")
objView.Apply
End Sub
Private Sub Items_ItemChange(ByVal Item As Object)
Dim Ns As Outlook.Namespace
Dim TaskFolder As Outlook.MAPIFolder
Dim Destfolder As Outlook.MAPIFolder
Set Ns = Application.GetNamespace("MAPI")
Set TaskFolder = Ns.GetDefaultFolder(olFolderTasks)
Set Destfolder = TaskFolder.Folders("Completed")
If TypeOf objItem Is Outlook.TaskItem Then
If objItem.Status = olTaskComplete Then
Item.Move Destfolder
MsgBox "Completed and moved to Completed Folder"
End If
End If
End Sub
Any thoughts as to what might need to be changed
Thanks
Roland