How to Quickly Jump to the Folder of a Found Item in Search Results via Outlook VBA

After completing an instant search, you may get a lot of search results in Outlook. In this case, you may want to quickly access to the parent folder of an item among the search results. This article will teach you how to realize it with VBA.

After reading the previous article “How to Get the Full Folder Paths of the Search Results with Outlook VBA”, many users long for another solution to directly jump to the folder of a search result. Therefore, in the followings, we’ll introduce such a method step by step.

Quickly Jump to the Folder of a Found Item in Search Results via Outlook VBA

Jump to the Folder of a Found Item in Search Results

  1. For a start, launch Outlook application.
  2. Then, press “Alt + F11” key buttons to access VBA editor.
  3. Next, copy the following VBA code into the “ThisOutlookSession” project.
Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Selection As Selection)
    Dim objCommandBarButton As Office.CommandBarButton
 
    If Selection.Count = 1 Then
       Set objCommandBarButton = CommandBar.Controls.Add(msoControlButton)
  
       With objCommandBarButton
            .Style = msoButtonIconAndCaption
            .Caption = "Jump To Folder"
            .FaceId = 331
            .OnAction = "Project1.ThisOutlookSession.JumpToFolder"
       End With
    End If
 
    Set objCommandBarButton = Nothing
End Sub

Sub JumpToFolder()
    Dim objItem As Object
    Dim objFolder As Outlook.Folder
    Dim objNewExplorer As Outlook.Explorer
 
    Set objItem = Application.ActiveExplorer.Selection(1)
    Set objFolder = objItem.Parent
 
    'Display the folder in a new Outlook window
    Set objNewExplorer = Outlook.Application.Explorers.Add(objFolder)
    objNewExplorer.Display
 
    'To directly open the folder in current window, use the following line instead
    'Set Outlook.Application.ActiveExplorer.CurrentFolder = objFolder
 
    Set objItem = Nothing
    Set objFolder = Nothing
    Set objNewExplorer = Nothing
End Sub

VBA Code - Jump to the Folder of a Found Item in Search Results

  1. After that, exit the current window.
  2. Finally, you can take a shot.
  • First off, perform a search, such as searching the emails containing the “Temp” text in subject.
  • Then, select one email in the search results.
  • Subsequently, right click on it and select “Jump To Folder” in the context menu.Run Macro through Context Menu
  • At once, a new Outlook explorer will display with the parent folder of the selected item opened, like the screenshot below.Opened New Window

Never Fear Outlook Crash

When Outlook crashes, generally, many users will get panic and afraid that their Outlook data will become damaged. Actually, as long as you have make sufficient precautions, your data will never vanish into air. For instance, if you have backed up your Outlook file, you’ll be able to recover PST data simply from the backup. If you have no backup, you still can make use of the in-built repair tool to try fixing the file. At worst, when Scanpst doesn’t make effects, you can use an experienced and credible 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 recovery and outlook repair software products. For more information visit www.datanumen.com

4 responses to “How to Quickly Jump to the Folder of a Found Item in Search Results via Outlook VBA”

  1. Generally I don’t read article on blogs, however I would like to say that this write-up very forced me to check out and do so! Your writing style has been amazed me. Thank you, quite nice article.

  2. Hi Guys,

    How to scroll to the folder using VBA – I can select the folder but the folder pane doesnt scroll to it??

    Many thanks,

    Philip

  3. I just tried the above code.

    Second part works great.

    I suppose the command bar reference is gone with the ribbon. I just made a link to the macro using the ribbon

Leave a Reply

Your email address will not be published. Required fields are marked *