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 find folder (full folder path) by folder name in Outlook?

For instance, on Navigation pane you move a folder and drop to an unknown folder by mistake in Outlook, you want to restore this folder but cannot find out it immediately. Unfortunately, Outlook does not support the Find feature same as that in Microsoft Word or Excel. Do not worry! You can apply a VBA macro to solve this problem in Outlook.

Find folder (full folder path) by folder name 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 bubbleFind folder (full folder path) by folder name with VBA

Please follow below steps to search for folders by folder names with VBA in Outlook.

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

2. Click Insert > Module, and then paste below VBA code into the new Module window.

VBA: Search and open folders by folder name in Outlook

Private m_Folder As MAPIFolder
Private m_Find As String
Private m_Wildcard As Boolean

Private Const SpeedUp As Boolean = True
Private Const StopAtFirstMatch As Boolean = True

Public Sub FindFolder()
Dim sName As String
Dim oFolders As Folders

  Set m_Folder = Nothing
m_Find = ""
m_Wildcard = False

  sName = InputBox("Find:", "Search folder")
If Len(Trim(sName)) = 0 Then Exit Sub
m_Find = sName

  m_Find = LCase(m_Find)
m_Find = Replace(m_Find, "%", "*")
m_Wildcard = (InStr(m_Find, "*"))

  Set oFolders = Application.Session.Folders
LoopFolders oFolders

  If Not m_Folder Is Nothing Then
If MsgBox("Activate folder: " & vbCrLf & m_Folder.FolderPath, vbQuestion Or vbYesNo) = vbYes Then
Set Application.ActiveExplorer.CurrentFolder = m_Folder
End If
Else
MsgBox "Not found", vbInformation
End If
End Sub

Private Sub LoopFolders(Folders As Outlook.Folders)
Dim oFolder As MAPIFolder
Dim bFound As Boolean

If SpeedUp = False Then DoEvents

  For Each oFolder In Folders
If m_Wildcard Then
bFound = (LCase(oFolder.Name) Like m_Find)
Else
bFound = (LCase(oFolder.Name) = m_Find)
End If

    If bFound Then
If StopAtFirstMatch = False Then
If MsgBox("Found: " & vbCrLf & oFolder.FolderPath & vbCrLf & vbCrLf & "Continue?", vbQuestion Or vbYesNo) = vbYes Then
bFound = False
End If
End If
End If
If bFound Then
Set m_Folder = oFolder
Exit For
Else
LoopFolders oFolder.Folders
If Not m_Folder Is Nothing Then Exit For
End If
Next
End Sub

3. Press F5 key or click the Run button to run this VBA.

4. In the popping out Search folder dialog box, please type the specified folder name you will search by, and click the OK button. See screenshot:

Note: This VBA supports asterisk wildcard. For example, you can type tes* to find out all folders whose name begin with tes.

5. Now a dialog box comes out and shows the folder path of found folder. If you need to open the found folder, please click the Yes button.

And now the found folder is opening on the Navigation pane as below screenshot shown:

Note: If there are more than one folders named with the specified name, this VBA can find and open one folder only.


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.
    Gabe Btg · 18 days ago
    Hello,

    Thank you for this macro. It works great!


    Is there a way to make the macro always search as wildcards? I would be easier to just type a keyword without adding the asterisks every time.
  • To post as a guest, your comment is unpublished.
    RapF · 1 months ago
    Hello.

    Wow - this is an amazing function, which will make my daily usage of Outlook tons faster.
    Thank you so much for publishing!!

    A tip for those interested:
    If you want to search only INBOX-folders, without public folders etc.
    This made it a lot faster for me because the public folder are remote, so the search is quite slow.
    And also I'm not interested in those results.


    Replace line 24 with:

    Set oFolders = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders
  • To post as a guest, your comment is unpublished.
    Adelino · 1 months ago
    Hello,

    Is there a way to search on my secondarymailbox aswell?


    Thank you and best regards,

    Gustavo
    • To post as a guest, your comment is unpublished.
      kellytte · 18 days ago
      Hi Adelino,
      The VBA introduced on this webpage is available for all mailboxes. As long as the folder has a unique name, this VBA can find out and open it, no matter which mailbox it is in. However, for those pubic folders, says Inbox, the VBA can only find out and open the very first one in the default mailbox.