Many people hope to quickly get the total number of tasks and appointments today in Outlook. Counting one by one manually is obviously error prone and troublesome. This article will look at this issue and introduce a method via Outlook VBA.
At times, due to carelessness or forgetfulness, many people may leave some tasks or appointments, which are saved in Outlook, aside. If some of them are indeed important missions, the consequences may be disastrous. So some people would like to quickly get how many tasks and appointments they have today. Sure, you can count them one by one. However, if the total number is quite a sum, it will be susceptible to error and rather cumbersome. In this case, you must desire a quick and convenient approach to swiftly get it. Fortunately, with Outlook VBA, you can achieve it without breaking a sweat. Here are detailed codes and steps.
Quickly Get the Total Number of Today’s Tasks and Appointments
- At first, start Outlook application.
- Then turn to “Developer” tab and click on “Visual Basic” button.
- The “Microsoft Visual Basic for Applications” window will open up. In it, you have to find and open a new module.
- Next copy and paste the following codes to the new module window.
Sub GetTotalNumberTodayTaskAppt() Dim olTasks As Outlook.Items Dim olResultTasks As Outlook.Items Dim oIAppts As Outlook.Items Dim olResultAppts As Outlook.Items Dim strFilter As String Dim obj As Object Dim i, n As Long Dim strMsg As String Dim nRes As Integer 'Get how many tasks today Set oITasks = Application.Session.GetDefaultFolder(olFolderTasks).Items strFilter = Format(Now, "ddddd") strFilter = "[Start Date] <= " & Chr(34) & strFilter & Chr(34) & " AND [Due Date] > " & Chr(34) & strFilter & Chr(34) Set olResultTasks = oITasks.Restrict(strFilter) For Each obj In olResultTasks i = i + 1 Next 'Get how many appointments today Set oIAppts = Application.Session.GetDefaultFolder(olFolderCalendar).Items oIAppts.Sort "[Start]", False oIAppts.IncludeRecurrences = True strFilter = Format(Now, "ddddd") strFilter = "[Start] <= " & Chr(34) & strFilter & " 11:59 PM" & Chr(34) & " AND [End] > " & Chr(34) & strFilter & " 00:00 AM" & Chr(34) Set olResultAppts = oIAppts.Restrict(strFilter) For Each obj In olResultAppts n = n + 1 Next 'Display a message box strMsg = "Warning:" & vbCrLf & "You have " & i & " tasks and " & n & " appointments TODAY, " & i + n & " missions in sum." & vbCrLf & "Don't forget any of them!" nRes = MsgBox(strMsg, vbExclamation, "Today Schedule") End Sub
- Subsequently, you can close the current window and continue to set Outlook macro level to low in “Macro Settings”.
- After that, click the down arrow in Quick Access Toolbar and choose “More Commands” from the drop down list.
- Later you can add the new macro to Quick Access Toolbar by following the steps shown in the image below:
- Finally you can have a try. After backing to the main Outlook window, you can click on the new button in Quick Access Toolbar and immediately you’ll get a message box, like the following screenshot:
Notes: Many users desire that Outlook can warn them as soon as they start the application. To fulfill this requirement, you can apply “Application.Startup” event. Replace “Sub GetTotalNumberTodayTaskAppt()” with “Sub Application_Startup()”. And then copy the codes into “ThisOutlookSession” project window. From now on, every time when you start Outlook, you’ll be reminded of the total number of the tasks and appointments today.
Cope with Frequent Outlook Issues
As we all know, no programs are foolproof. The same holds true for Outlook. So if you intend to use Outlook for decades, you have to prepare for its frequent errors, such as sudden freezing, no responding, occasional error messages and Outlook PST email damage. One of the most advisable precautions is to keep a potent PST fix tool handy, like DataNumen Outlook Repair, which will come to your rescue when you encounter serious outlook issues.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair corrupted SQL mdf and outlook repair software products. For more information visit www.datanumen.com
Leave a Reply