---
description: Multiple users hope that all the folders can be automatically expanded when they launch their Outlook. In reality, Outlook doesn’t natively support it. Thus, to realize it, you have to use VBA code. This post will give you a quick guide.
title: How to Auto Expand All Folders via VBA when Starting Your Outlook
image: https://www.datanumen.com/blogs/wp-content/uploads/2018/03/vba-code-auto-expand-folders-on-outlook-startup.jpg
---

-
-
-

[Home](https://www.datanumen.com/blogs/) > [Solutions](https://www.datanumen.com/blogs/category/solutions/) > [Office Solutions](https://www.datanumen.com/blogs/category/solutions/office-solutions/) > [Outlook Solutions](https://www.datanumen.com/blogs/category/solutions/office-solutions/outlook-solutions/) > How to Auto Expand All Folders via VBA when Starting Your Outlook

# How to Auto Expand All Folders via VBA when Starting Your Outlook

[Outlook Solutions](https://www.datanumen.com/blogs/category/solutions/office-solutions/outlook-solutions/) September 29, 2025

Share Now:

-
-
-
-
-
-
-
-

*Multiple users hope that all the folders can be automatically expanded when they launch their Outlook. In reality, Outlook doesn’t natively support it. Thus, to realize it, you have to use VBA code. This post will give you a quick guide.*

You may have created a lot of subfolders under the default folders in Outlook. In face of so many folders, so as to quickly access them at any time, you may wish to keep all the folders expanded all the time. The first step must be to make Outlook to auto expand the folders on startup. Obviously, there isn’t such a native function in Outlook. Thus, you have to make use of macros. Thereinafter, we will teach you to achieve it with VBA. As for how to apply VBA, you can refer to another article – “ [How to Run VBA Code in Your Outlook](https://www.datanumen.com/blogs/run-vba-code-outlook/)“.

## Auto Expand All Folders when Starting Outlook

1. To begin with, press “Alt + F11” in your Outlook to access VBA editor.
2. Then, in the new window, put the code into the “ThisOutlookSession” project.

```
'Auto expand all folders on startup
Private Sub Application_Startup()
    Call ExpandAllFolders
End Sub

Private Sub ExpandAllFolders()
    Dim objCurrentFolder As Outlook.Folder
    Dim objStore As Outlook.Store
    Dim objFileFolders As Outlook.Folders
    Dim objFolder As Outlook.Folder
   
    Set objCurrentFolder = Application.ActiveExplorer.CurrentFolder
 
    'Process all email accounts in your Outlook
    For Each objStore In Outlook.Application.Session.Stores
        Set objFileFolders = objStore.GetRootFolder.Folders
 
        For Each objFolder In objFileFolders
            Call LoopFolders(objFolder)
        Next
 
        DoEvents
        Set Application.ActiveExplorer.CurrentFolder = objCurrentFolder
    Next
End Sub

Sub LoopFolders(ByVal objCurFolder As Outlook.Folder)
    Dim objSubfolder As Outlook.Folder
 
    Set Application.ActiveExplorer.CurrentFolder = objCurFolder
    DoEvents
 
    'Process all subfolders recursively
    If objCurFolder.Folders.Count > 0 Then
       For Each objSubfolder In objCurFolder.Folders
           Call LoopFolders(objSubfolder)
       Next
    End If
End Sub
```

![VBA Code - Auto Expand All Folders when Starting Outlook](<> "VBA Code - Auto Expand All Folders when Starting Outlook")

3. After that, close the VBA editor.
4. Subsequently, exit the Outlook application properly.
5. Later, start your Outlook. At this point, the macro will run automatically.
6. After Outlook starts up, you can see that all the folders have been expanded, as shown in the figure below.![All Folders Are Expanded](<> "All Folders Are Expanded")

## Keep All Malicious Macros at Bay

Have you ever received the emails which are attached with suspicious files or are embedded with unknown links? Usually, when confronting such emails, you have to raise your vigilance. You should never readily trust in them in that they might carry viruses. Once you download the attachments or open the links, not only the Outlook but also the computer might be attacked. At that time, you have to [repair Outlook](https://www.datanumen.com/outlook-repair/) file. It could be quite knotty unless you have an updated Outlook backup or make use of a powerful recovery tool, such as 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 [SQL Server corruption](https://www.datanumen.com/sql-recovery/) and outlook repair software products. For more information visit [www.datanumen.com](https://www.datanumen.com/)

Share Now:

-
-
-
-
-
-
-
-

[← Previous post](https://www.datanumen.com/blogs/is-it-possible-to-back-up-both-mac-and-windows-systems-to-the-same-external-hard-drive/)

[Next post →](https://www.datanumen.com/blogs/4-most-common-risks-to-data-during-system-update/)

Comments are closed.

![Data Recovery Blog]()

Follow or like us on Facebook, LinkedIn and Twitter to get all promotions, latest news and updates on our products and company.

-
-
-

### Featured Products

- [DataNumen Outlook Repair](https://www.datanumen.com/outlook-repair/)
- [DataNumen SQL Recovery](https://www.datanumen.com/sql-recovery/)
- [DataNumen Exchange Recovery](https://www.datanumen.com/exchange-recovery/)
- [DataNumen Access Repair](https://www.datanumen.com/access-repair/)
- [DataNumen Excel Repair](https://www.datanumen.com/excel-repair/)
- [DataNumen PDF Repair](https://www.datanumen.com/pdf-repair/)
- [DataNumen Word Repair](https://www.datanumen.com/word-repair/)
- [DataNumen Zip Repair](https://www.datanumen.com/zip-repair/)

### Popular posts

```json
{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.datanumen.com\/blogs\/how-to-auto-expand-all-folders-via-vba-when-starting-your-outlook\/#article","isPartOf":{"@id":"https:\/\/www.datanumen.com\/blogs\/how-to-auto-expand-all-folders-via-vba-when-starting-your-outlook\/"},"author":{"name":"AuthorCCW","@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/person\/33ded6c47c77587f9158d99f05e23957"},"headline":"How to Auto Expand All Folders via VBA when Starting Your Outlook","datePublished":"2018-03-22T03:59:07+00:00","dateModified":"2025-09-29T05:56:05+00:00","mainEntityOfPage":{"@id":"https:\/\/www.datanumen.com\/blogs\/how-to-auto-expand-all-folders-via-vba-when-starting-your-outlook\/"},"wordCount":373,"commentCount":1,"publisher":{"@id":"https:\/\/www.datanumen.com\/blogs\/#organization"},"image":{"@id":"https:\/\/www.datanumen.com\/blogs\/how-to-auto-expand-all-folders-via-vba-when-starting-your-outlook\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2018\/03\/vba-code-auto-expand-folders-on-outlook-startup.jpg","articleSection":["Outlook Solutions"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.datanumen.com\/blogs\/how-to-auto-expand-all-folders-via-vba-when-starting-your-outlook\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.datanumen.com\/blogs\/how-to-auto-expand-all-folders-via-vba-when-starting-your-outlook\/","url":"https:\/\/www.datanumen.com\/blogs\/how-to-auto-expand-all-folders-via-vba-when-starting-your-outlook\/","name":"How to Auto Expand All Folders via VBA when Starting Your Outlook","isPartOf":{"@id":"https:\/\/www.datanumen.com\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.datanumen.com\/blogs\/how-to-auto-expand-all-folders-via-vba-when-starting-your-outlook\/#primaryimage"},"image":{"@id":"https:\/\/www.datanumen.com\/blogs\/how-to-auto-expand-all-folders-via-vba-when-starting-your-outlook\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2018\/03\/vba-code-auto-expand-folders-on-outlook-startup.jpg","datePublished":"2018-03-22T03:59:07+00:00","dateModified":"2025-09-29T05:56:05+00:00","description":"Multiple users hope that all the folders can be automatically expanded when they launch their Outlook. In reality, Outlook doesn’t natively support it. Thus, to realize it, you have to use VBA code. This post will give you a quick guide.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.datanumen.com\/blogs\/how-to-auto-expand-all-folders-via-vba-when-starting-your-outlook\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanumen.com\/blogs\/how-to-auto-expand-all-folders-via-vba-when-starting-your-outlook\/#primaryimage","url":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2018\/03\/vba-code-auto-expand-folders-on-outlook-startup.jpg","contentUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2018\/03\/vba-code-auto-expand-folders-on-outlook-startup.jpg","width":773,"height":426,"caption":"VBA Code - Auto Expand All Folders when Starting Outlook"},{"@type":"WebSite","@id":"https:\/\/www.datanumen.com\/blogs\/#website","url":"https:\/\/www.datanumen.com\/blogs\/","name":"Data Recovery Blog","description":"Discuss every aspect of data recovery","publisher":{"@id":"https:\/\/www.datanumen.com\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.datanumen.com\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.datanumen.com\/blogs\/#organization","name":"Data Recovery Blog","url":"https:\/\/www.datanumen.com\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2019\/02\/logowithouttext.jpg","contentUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2019\/02\/logowithouttext.jpg","width":296,"height":397,"caption":"Data Recovery Blog"},"image":{"@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataNumen","https:\/\/x.com\/DataNumen","http:\/\/www.linkedin.com\/company\/datanumen","https:\/\/myspace.com\/datanumen\/","http:\/\/www.pinterest.com\/datanumen\/","https:\/\/www.youtube.com\/channel\/UCVIIuuKfUBHSJauUaVP13tw"]},{"@type":"Person","@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/person\/33ded6c47c77587f9158d99f05e23957","name":"AuthorCCW","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3516ed90fc242780d3947a989f895bc46e70c3e83485d30f2b457a007906aa58?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3516ed90fc242780d3947a989f895bc46e70c3e83485d30f2b457a007906aa58?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3516ed90fc242780d3947a989f895bc46e70c3e83485d30f2b457a007906aa58?s=96&d=mm&r=g","caption":"AuthorCCW"},"sameAs":["https:\/\/www.datanumen.com\/"]}]}
```
