At times, you may want to expand or collapse all mail folders in the mail navigation pane in one go. In this case, you can utilize the methods introduced in this post.
For some reasons, such as to check the emails in different folders and subfolders more conveniently, you may want to expand all the mail folders. Equally, when you feel that keeping all folders expanded makes your mail navigation pane looks too complex, you may wish to collapse all the folders. At this point, if you expand or collapse them manually via clicking one by one, it will be considerably tedious. Therefore, you must long for a much quick method that can expand or collapse all the mail folders in one go. Now, here we will unveil such a means to you.
Expand All Mail Folders
- In the first place, start your Outlook program normally.
- Then press “Alt + F11” key buttons in the main Outlook window.
- Next in the Outlook VBA editor window, open a blank module.
- Subsequently, copy the following VBA codes into this module.
Sub ExpandAllMailFolders() Dim objCurrentFolder As Outlook.Folder Dim objPSTFolders As Outlook.Folders Dim objFolder As Outlook.Folder Set objCurrentFolder = Application.ActiveExplorer.CurrentFolder 'Specify a specific pst file 'Change "PSTName" to the name of your own Outlook PST file Set objPSTFolders = Application.Session.Folders("PSTName").Folders For Each objFolder In objPSTFolders Call ProcessFolder(objFolder) Next DoEvents Set Application.ActiveExplorer.CurrentFolder = objCurrentFolder End Sub Sub ProcessFolder(ByVal objCurFolder As Outlook.Folder) Dim objSubfolder As Outlook.Folder 'Only expand the mail folders If objCurFolder.DefaultItemType = olMailItem Then Set Application.ActiveExplorer.CurrentFolder = objCurFolder DoEvents 'Process all subfolders recursively If objCurFolder.Folders.Count > 0 Then For Each objSubfolder In objCurFolder.Folders Call ProcessFolder(objSubfolder) Next End If End If End Sub
- After that, you can click the “Run Sub” button in the toolbar or press F5 key to trigger the new macro.
- Immediately, all the mail folders in the predefined Outlook PST file will be expanded.
Collapse All Mail Folders
Compared with expanding all mail folders, collapsing is much easier. You can just collapse the root of the specific Outlook PST file and then expand it again. To do it, you can click on the arrow in front of the top-level folder of the PST file, like the following screenshot. After that, re-click the arrow to expand the file. You can see that all the subfolders have been collapsed.
Handle Troublesome PST Errors Flexibly
Have you ever received any error messages during using Outlook? If you’ve used Outlook for decades, you must have. Without any doubts, Outlook is vulnerable to errors. Thus, in order to better safeguard your Outlook data, you have to back up your Outlook PST file on a periodical basis. Moreover, it’s suggested to keep a PST fix tool in vicinity, 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 sql and outlook repair software products. For more information visit www.datanumen.com
Leave a Reply