Moving Task on completion to Archive

Joined
Feb 26, 2011
Messages
3
Reaction score
1
This is my attempt at this using the itemchange event but the code does not work on moving the task any idea why. It is finding the right task as the categories are being removed it just will not move to the Completed folder. Any help would be very much appreciated. The code I have is as follows:

Private WithEvents Items As Outlook.Items

Private Sub Class_Initialize()
Dim Ns As Outlook.NameSpace
Dim DestFolder As Outlook.Folder
Set Ns = Application.GetNamespace("MAPI")
Set TaskFolder = Ns.GetDefaultFolder(olFolderTasks)
Set Items = TaskFolder.Items
Set DestFolder = TaskFolder.Folders("Completed") ' Subfolder of the Task Folder
End Sub

Private Sub Items_ItemChange(ByVal Item As Object)

Dim Task As Outlook.TaskItem
Dim TaskCopy As Outlook.TaskItem

If TypeOf Item Is Outlook.TaskItem Then
Set Task = Item

If Task.Status = olTaskComplete Then
Task.Categories = ""
Task.Save
Task.Move DestFolder
End If
End If

End Sub
 

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