In order to prevent cluttering up your task list, many users tend to utilize different subject for different tasks. In this article, we will expose a piece of VBA code which can let Outlook warn you when new task has same subject as an existing ones.
If you have many tasks which have the same subjects, not only will you find it a bit difficult to distinguish them in the Outlook task list, but also there may be some duplicate ones among them. Therefore, it is suggested not to use the same subjects for tasks. However, in reality, if you have multiple existing tasks, it can be tedious for you to check all of their subjects when creating a new task. Thus, why not use the following VBA code to let Outlook auto check and warn you if the new task subject is same as an existing one? Now read on to get them in detail.
Get Warned When New Task Has the Same Subject as an Existing One
- To start with, launch your Outlook program.
- Then press “Alt + F11” key buttons in main Outlook window.
- Next in the emerging “Microsoft Visual Basic for Applications” window, open the “ThisOutlookSession” project window.
- Subsequently, copy and paste the following VBA codes into this project.
Public WithEvents objTasks As Outlook.Items Private Sub Application_Startup() Set objTasks = Outlook.Application.Session.GetDefaultFolder(olFolderTasks).Items End Sub Private Sub objTasks_ItemAdd(ByVal Item As Object) Dim strSubject As String Dim strFilter As String Dim objRestrictedTasks As Outlook.Items Dim strMsg As String Dim nWarning As Integer strSubject = Item.Subject 'Find the tasks in the same subject strFilter = "[Subject] <= " & Chr(34) & strSubject & Chr(34) Set objRestrictedTasks = objTasks.Restrict(strFilter) 'If there are such tasks, display a warning If objRestrictedTasks.Count >= 2 Then strMsg = "The new task has the same subject as the exsiting ones." & vbCrLf & "Do you want to change the new task subject?" nWarning = MsgBox(strMsg, vbExclamation + vbYesNo, "Check Task Subject") 'If select "Yes" button 'Display the new task for you to change subject If nWarning = vbYes Then Item.Display End If End If End Sub
- After that, you ought to assign a digital certificate to the current VBA project.
- Later you need to change Outlook macro settings to allow the signed macros.
- Eventually you can restart your Outlook to activate the new macro.
- From now on, every time when a new task is created and saved in the default Tasks folder, Outlook will check if its subject is the same as an existing ones. If so, you will get a warning like the following screenshot:
- When you select “Yes”, the new task will display for you to change its subject.
Avert Painful PST Data Loss
Despite boasting of multiple Outlook issues, your Outlook still cannot be immune from errors and crashes. If your Outlook often crashes, your PST file will tend to get corrupted. As long as your PST gets damaged, you will make efforts to repair PST. It can be pretty easy if you have PST data backups in hand. Otherwise, you’ll need to recur to a potent tool like DataNumen Outlook Repair.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupt sql and outlook repair software products. For more information visit www.datanumen.com