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:
Kutools for Outlook
More than 100 Advanced Functions for Outlook 2010, 2013, 2016, 2019 and 365