How to open all subfolders from Outlook?
If you create multiple subfolders under your Outlook folders, how could you open or expand all of these subfolders immediately? This article, I will introduce a useful VBA code for you to solve this job.
Please apply the following VBA code to expand all subfolders from all Outlook accounts:
1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following macro in the Module Window.
VBA code: Open all subfolders from Outlook:
Sub ExpandAllMailFolders() Dim xCurrentFolder As Folder Dim xAllFolders As Folders Dim xFolder As Folder On Error Resume Next Set xCurrentFolder = Application.ActiveExplorer.CurrentFolder Set xAllFolders = Application.Session.Folders For Each xFolder In xAllFolders Call ProcessFolders(xFolder) Next Set Application.ActiveExplorer.CurrentFolder = xCurrentFolder End Sub Sub ProcessFolders(ByVal CurFolder As Folder) Dim xSubfolder As Folder On Error Resume Next If CurFolder.DefaultItemType <> olMailItem Then Exit Sub Set Application.ActiveExplorer.CurrentFolder = CurFolder DoEvents If CurFolder.Folders.Count = 0 Then Exit Sub For Each xSubfolder In CurFolder.Folders Call ProcessFolders(xSubfolder) Next End Sub
3. Then press F5 key to run this code, and all subfolders in all accounts of your Outlook have been expanded, see screenshot:
Best Office Productivity Tools
Kutools for Outlook - Over 100 Powerful Features to Supercharge Your Outlook
Over 100 Features Await Your Exploration! Click Here to Discover More.