Some users are eager to auto insert and update countdown days in tasks’ subjects. So, in this article, we will introduce an intelligent approach to get it.
When you open a task, you will definitely see the “Due in XX days” screen tip in the header. Nevertheless, since you are used to checking task directly in the list, you may hope to see such countdown tip straightly in the task subject. Therefore, in the followings, we’ll share a smart way to auto insert and update countdown days in tasks’ subjects.
Auto Insert & Update Countdown Days in Tasks’ Subjects
- For a start, trigger Outlook VBA editor by referring to the article – “How to Run VBA Code in Your Outlook“.
- Next, in the “ThisOutlookSession” project, put the following VBA code.
Private WithEvents objTasks As Outlook.Items Private objItem As Object Private Sub Application_Startup() Set objTasks = Outlook.Application.Session.GetDefaultFolder(olFolderTasks).Items 'Auto Update Countdown Days in All Tasks' Subjects on Startup For Each objItem In objTasks Call UpdateCountdownDays(objItem) Next End Sub 'Auto Insert the Countdown Days to New Tasks' Subjects Private Sub objTasks_ItemAdd(ByVal Item As Object) Dim objTask As Outlook.TaskItem Dim lCountdownDays As Long If Item.Class = olTask Then Set objTask = Item With objTask lCountdownDays = .DueDate - Date .Subject = .Subject & " (Due in " & lCountdownDays & " days)" .Save End With End If End Sub 'Auto Update Countdown Days when Changing Tasks Private Sub objTasks_ItemChange(ByVal Item As Object) Call UpdateCountdownDays(Item) End Sub Private Sub UpdateCountdownDays(ByVal objItem As Object) Dim objTask As Outlook.TaskItem Dim strSubject As String Dim strCountdownNotes As String Dim lCountdownDays As Long If objItem.Class = olTask Then Set objTask = objItem strSubject = objTask.Subject 'Replace the Old Countdown Days with New Value in Task Subject If InStr(1, strSubject, "Due in") > 0 Then strCountdownNotes = Right(strSubject, Len(strSubject) - InStr(1, strSubject, "(Due in") + 1) With objTask lCountdownDays = .DueDate - Date .Subject = Replace(objTask.Subject, strCountdownNotes, "(Due in " & lCountdownDays & " days)") .Save End With End If End If End Sub
- After that, restart your Outlook application.
- Since then, every time when you create a new Task, Outlook will auto insert the countdown days into its subject.
- Besides, as long as you start Outlook or make modifications in a task, Outlook will auto update the countdown days.
What to Do if Coming across Outlook Corruption
It is known that Outlook is susceptible to damage. Thus, have you ever suffered it or imagined about how to deal with it effective? In general, as long as you’ve kept making Outlook data backups, you can simply restore data from backups. If there aren’t backups, you have no choice but to resort to a potent external fix tool, such as DataNumen Outlook Repair, to recover PST data.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupt mdf and outlook repair software products. For more information visit www.datanumen.com