Missing outlook folder Macro finder

Have you lost the location of one of your folders in outlook?

You are not sure where did you place at?

Easy solution

Today we are going to create a macro in order to find our lost folder.

  • Pre-requisite

Ensure macros are activated!

2017-12-07 19_50_14-Trust Center

  1. First of all, we are going to open the macro menu (ALT plus F11)
  2. We will do a new object as follows (new project/insert module )

2017-12-07 19_45_00-Microsoft Visual Basic for Applications - VbaProject.OTM [design]

3.We will insert the following code into the module

2017-12-07 19_45_34-Microsoft Visual Basic for Applications - VbaProject.OTM [design]

—- BEGIN OF COPY/PASTE—-

Private m_Folder As Outlook.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 Name$
Dim Folders As Outlook.Folders

Set m_Folder = Nothing
m_Find = “”
m_Wildcard = False

Name = InputBox(“Find name:”, “Search folder”)
If Len(Trim$(Name)) = 0 Then Exit Sub
m_Find = Name

m_Find = LCase$(m_Find)
m_Find = Replace(m_Find, “%”, “*”)
m_Wildcard = (InStr(m_Find, “*”))

Set Folders = Application.Session.Folders
LoopFolders Folders

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 F As Outlook.MAPIFolder
Dim Found As Boolean

If SpeedUp = False Then DoEvents

For Each F In Folders
If m_Wildcard Then
Found = (LCase$(F.Name) Like m_Find)
Else
Found = (LCase$(F.Name) = m_Find)
End If

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

 

—- END COPY/ PASTE—-

4. We will save the process & hence run it ( save icon & run button )

2017-12-07 19_46_01-Microsoft Visual Basic for Applications - VbaProject.OTM [design]

5.Select the desired macro

2017-12-07 19_46_15-Microsoft Visual Basic for Applications - VbaProject.OTM [design]

5. Macro will show the following picture

2017-12-07 19_49_52-Inbox - antonio@fluent2.co.uk - Outlook

Just now type the folder name and the macro will automatically highlight the folder.

Happy days!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.