Perhaps you configured several email accounts in your Outlook and each one has its own Outlook files. Now, if you would like to quickly count all items in each Outlook file, you can use the method shared in this article.
At times, you may need to get the count of all items in an Outlook file. In this case, usually, you need to process all the folders one by one. Apparently, it is quite troublesome. In reality, with a bit of scripting, you can accomplish this task with effortless ease. Now, in the followings, we will share you a piece of VBA code that is able to get the counts of all items in each open Outlook file. Please read on to get the details.
Quickly Count All Items in Each Outlook File
- For a start, trigger Outlook VBA editor according to “How to Run VBA Code in Your Outlook“.
- Then, copy and paste the following code into a module.
Sub CountAllItems_AllOutlookFiles() Dim objStores As Outlook.Stores Dim objStore As Outlook.Store Dim objOutlookFile As Outlook.Folder Dim i As Integer Dim lItemCount As Long Set objStores = Outlook.Session.Stores lItemCount = 0 'Process all Outlook data files For i = objStores.Count To 1 Step -1 Set objStore = objStores.Item(i) Set objOutlookFile = objStore.GetRootFolder Call ProcessFolders(objOutlookFile.Folders, lItemCount) strlist = "All Items in " & Chr(34) & objOutlookFile.Name & Chr(34) & ": " & lItemCount & vbCr & strlist lItemCount = 0 Next 'Prompt you of the counts MsgBox strlist, vbInformation + vbOKOnly, "Item Count" End Sub Sub ProcessFolders(ByVal objCurFolders As Outlook.Folders, lCurCount As Long) Dim objFolder As Outlook.Folder Dim objSubFolder As Outlook.Folder 'Count items For Each objFolder In objCurFolders lCurCount = objFolder.Items.Count + lCurCount If objFolder.Folders.Count > 0 Then Call ProcessFolders(objFolder.Folders, lCurCount) End If Next End Sub
- After that, click into the first subroutine.
- Finally, click “Run” icon in the toolbar or directly press “F5” key button.
- At once, when macro finishes, you’ll get a message like the following figure.
Cope with Annoying Outlook Issues
Provided that you’ve used Outlook for decades, you must have encountered a lot of problems in Outlook. Then, you must long for some methods to effectively deal with them. Generally, in the first step, you can try the inbox repair tool, Scanpst. It is able to help you fix majority of small issues in Outlook. However, if it fails, you have no choice but to take aid of a reliable and more potent tool, like DataNumen Outlook Repair.
Author Introduction:
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupted mdf and outlook repair software products. For more information visit www.datanumen.com
Leave a Reply