Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to automatically expand all folders when starting Outlook?

Generally speaking, if you expand or collapse a folder on the Navigation Pane and then close the Outlook, the folder will remain expanding or collapsing when restarting Outlook. But now, is there a way to expand all folders automatically when starting Outlook? This article will introduce a VBA to complete the task.

Automatically expand all folders when starting Outlook with VBA

Office Tab - Enable Tabbed Editing and Browsing in Office, and Make Work Much Easier...
Kutools for Outlook - Brings 100 Powerful Advanced Features to Microsoft Outlook
  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by rules; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails at once; Auto Add Greeting when reply; Auto Add Date&Time into subject...
  • Attachment Tools: Auto Detach, Compress All, Rename All, Auto Save All... Quick Report, Count Selected Mails, Remove Duplicate Mails and Contacts...
  • More than 100 advanced features will solve most of your problems in Outlook 2010-2019 and 365. Full features 60-day free trial.

arrow blue right bubbleAutomatically expand all folders when starting Outlook with VBA

This method will introduce a VBA to automatically expand all folders on the Navigation Pane when you start Outlook. Please apply this VBA as follows:

1. Press Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.

2. Expand the Project 1 and Microsoft Outlook Objects in the Project pane, double click to open the ThisOutlookSession window, and then paste below VBA code into it.

VBA: Automatically expand all folders in Outlook

Private Sub Application_Startup()
ExpandAllFolders
End Sub

Private Sub ExpandAllFolders()
On Error Resume Next
Dim Ns As Outlook.NameSpace
Dim Folders As Outlook.Folders
Dim CurrF As Outlook.MAPIFolder
Dim F As Outlook.MAPIFolder
Dim ExpandDefaultStoreOnly As Boolean

  ExpandDefaultStoreOnly = False

  Set Ns = Application.GetNamespace("Mapi")
Set CurrF = Application.ActiveExplorer.CurrentFolder

  If ExpandDefaultStoreOnly = True Then
Set F = Ns.GetDefaultFolder(olFolderInbox)
Set F = F.Parent
Set Folders = F.Folders
LoopFolders Folders, True

  Else
LoopFolders Ns.Folders, True
End If

  DoEvents
Set Application.ActiveExplorer.CurrentFolder = CurrF
End Sub

Private Sub LoopFolders(Folders As Outlook.Folders, _
ByVal bRecursive As Boolean _
)
Dim F As Outlook.MAPIFolder

  For Each F In Folders
Set Application.ActiveExplorer.CurrentFolder = F
DoEvents

    If bRecursive Then
If F.Folders.Count Then
LoopFolders F.Folders, bRecursive
End If
End If
Next
End Sub

3. Save the code and close the Microsoft Visual Basic for Applications window.

From now on, when restarting Outlook, all folders will be automatically expanded in Outlook.Note: This VBA cannot open the collapsed search folders when restarting Outlook.


arrow blue right bubbleRelated Articles


Kutools for Outlook - Brings 100 Advanced Features to Outlook, and Make Work Much Easier!

  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by custom; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails in seconds; Auto Add Greeting when reply; Add Date into subject...
  • Attachment Tools: Manage All Attachments in All Mails, Auto Detach, Compress All, Rename All, Save All... Quick Report, Count Selected Mails...
  • Powerful Junk Emails by custom; Remove Duplicate Mails and Contacts... Enable you to do smarter, faster and better in Outlook.
shot kutools outlook kutools tab 1180x121
shot kutools outlook kutools plus tab 1180x121
 
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Selvi · 1 years ago
    Thank you so much.. It solved my problem. :)