Sytone's Ramblings

The occasional posts of a guy who plays with technology.

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

2012-10-15 1 min read Productivity

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]