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.
Open or expand all subfolders from Outlook with VBA code
Open or expand all subfolders from Outlook with VBA code
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
Breaking News: Kutools for Outlook Launches Free Version!
Experience the all-new Kutools for Outlook FREE version with 70+ incredible features, yours to use FOREVER! Click to download now!
π€ Kutools AI : Uses advanced AI technology to handle emails effortlessly, including replying, summarizing, optimizing, extending, translating, and composing emails.
π§ Email Automation: Auto Reply (Available for POP and IMAP) / Schedule Send Emails / Auto CC/BCC by Rules When Sending Email / Auto Forward (Advanced Rules) / Auto Add Greeting / Automatically Split Multi-Recipient Emails into Individual Messages ...
π¨ Email Management: Recall Emails / Block Scam Emails by Subjects and Others / Delete Duplicate Emails / Advanced Search / Consolidate Folders ...
π Attachments Pro: Batch Save / Batch Detach / Batch Compress / Auto Save / Auto Detach / Auto Compress ...
π Interface Magic: πMore Pretty and Cool Emojis / Remind you when important emails come / Minimize Outlook Instead of Closing ...
π One-click Wonders: Reply All with Incoming Attachments / Anti-Phishing Emails / πShow Sender's Time Zone ...
π©πΌβπ€βπ©π» Contacts & Calendar: Batch Add Contacts From Selected Emails / Split a Contact Group to Individual Groups / Remove Birthday Reminders ...