Recommended Posts

hello,

I have a lot of subfolders in my outlook. So when I want to find some special emails I need to open all subfolders to check. So I have to expand them one by one manually.

But it's easy to colse them all, just click to collapse the root of the pst file. So I hope I can quickly expand all subfolders by only clicking a button or something else just like I close them. How to set it in outlook?

Link to post
Share on other sites

hello,

You can do that via VBA. I find a article online which may be just what you want. Below is the codes:

Sub ExpandAllMailFolders()
    Dim objCurrentFolder As Outlook.Folder
    Dim objPSTFolders As Outlook.Folders
    Dim objFolder As Outlook.Folder

    Set objCurrentFolder = Application.ActiveExplorer.CurrentFolder
    'Specify a specific pst file
    'Change "PSTName" to the name of your own Outlook PST file
    Set objPSTFolders = Application.Session.Folders("PSTName").Folders
 
    For Each objFolder In objPSTFolders
        Call ProcessFolder(objFolder)
    Next

    DoEvents
    Set Application.ActiveExplorer.CurrentFolder = objCurrentFolder
End Sub

Sub ProcessFolder(ByVal objCurFolder As Outlook.Folder)
    Dim objSubfolder As Outlook.Folder
 
    'Only expand the mail folders
    If objCurFolder.DefaultItemType = olMailItem Then
       Set Application.ActiveExplorer.CurrentFolder = objCurFolder
       DoEvents
 
       'Process all subfolders recursively
       If objCurFolder.Folders.Count > 0 Then
          For Each objSubfolder In objCurFolder.Folders
              Call ProcessFolder(objSubfolder)
          Next
       End If
    End If
End Sub

you can create a  button for this macro. so you can click the button to expand all subfolders. And here is the link of the article

 

https://www.datanumen.com/blogs/quickly-expand-collapse-mail-folders-outlook/

 

Hope it helps

 

 

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...