Outlook has an option to show either the number of unread messages or the total number of messages in a folder.
To change the setting, you right click on the folder, choose Properties then select the desired option, Show number of unread items or Show total number of items.
If you have a large number of folders to change, this task can take a lot of time as you need to change the property on each folder one at a time. You can speed this up using a VBA macro.
If you have multiple data files in your profile and want to change the setting for just one data file, you'll need to use an If statement to check for the data file name. The data file name is the top folder in the folder list and listed in the Properties dialog (in the Location field) when you view the Properties of any folder, as seen in the Properties screenshot above.
After running the macro, select the data file name to refresh the view. All folders, including subfolders, will be updated.
Sub TotalUnreadCount() ' store is a pst file Dim App As New Outlook.Application Dim Stores As Outlook.Stores Dim Store As Outlook.Store Dim Root As Outlook.Folder On Error Resume Next Set Stores = App.Session.Stores For Each Store In Stores Set Root = Store.GetRootFolder ' Use If statemnet to apply to a specific data file ' Otherwise, all folders in ALL data files in the profile are changed ' display name is in the location field of the Properties dialog 'If Root = "data file display name" Then ChangeShowCount Root 'End If Next End Sub Private Sub ChangeShowCount(ByVal Root As Outlook.Folder) Dim Folders As Outlook.Folders Dim Folder As Outlook.Folder Dim Foldercount As Integer On Error Resume Next Set Folders = Root.Folders Foldercount = Folders.Count If Foldercount Then For Each Folder In Folders 'ShowTotal Count Folder.ShowItemCount = olShowTotalItemCount 'Show UnreadCount 'Folder.ShowItemCount = olShowUnreadItemCount ChangeShowCount Folder Next End If End Sub
First: You will need macro security set to low during testing.
To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor