MYN/1MTD and setting the Start Date in Outlook automagically.

Posted by Jon Bullen on 2012-10-15
Estimated Reading Time 1 Minutes
Words 182 In Total

If you are using Outlook and want to force the start date to be set with a due date in the future by default you can use a macros which automatically runs for any new task item. In the VBA editor (Alt+F11) open up ThisOutlookSession In the code window add the following: [code lang=”vb”] Option Explicit Public WithEvents Items As Outlook.Items Private Sub Application_Startup() Initialize_handler End Sub Public Sub Initialize_handler() Dim objNS As Outlook.NameSpace Set objNS = GetNamespace(“MAPI”) Set Items = objNS.GetDefaultFolder(olFolderTasks).Items End Sub Private Sub Items_ItemAdd(ByVal Item As Object) On Error GoTo errHandler Dim objNS As Outlook.NameSpace Set objNS = GetNamespace(“MAPI”) If TypeOf Item Is Outlook.TaskItem Then Dim Task As Outlook.TaskItem Set Task = Item ‘1/1/4501 is None in the Outlook world. If Task.StartDate = #1/1/4501# Then Task.StartDate = Now() Task.DueDate = Now() + 3000 ‘ A due date a long way into the future. Task.Save End If End If Exit Sub errHandler: MsgBox “Error “ & Err.Number & “: “ & Err.Description & “ in “, vbOKOnly, “Error” End Sub [/code]

If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you!