I met Andrew (@stinkydrew) on Twitter today when I responded to an Outlook related tweet. The initial tweet asked how to determine the parent folder of an item found during a search. By the time I responded Andrew had already discovered the answer to that question and had a new, albeit implied, question:
i found how to find where the email is located but now I cant find the folder DOH!
That’s a good point. If the item is in a folder that’s nested under one or more other folders, then it could be hard to find. Wouldn’t it be handy if there was a way to jump directly to the folder an item is in?
Scripting to the rescue. With a few lines of code we can do just that. The code below shows how to do this. It opens an Outlook explorer window on the parent folder of the currently selected item (if in an explorer view) or the currently open item (if an item is open). Armed with this macro Andrew should be able to find the folder the item is in with ease.
Instructions.
- Start Outlook
- Click Tools > Macro > Visual Basic Editor
- If not already expanded, expand Microsoft Office Outlook Objects
- If not already expanded, expand Modules
- Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
- Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
- Click the diskette icon on the toolbar to save the changes
- Close the VB Editor
Sub JumpToFolder() Dim olkMsg As Object, olkExp As Outlook.Explorer Select Case TypeName(Application.ActiveWindow) Case "Explorer" Set olkMsg = Application.ActiveExplorer.Selection(1) Case "Inspector" Set olkMsg = Application.ActiveInspector.CurrentItem End Select Set olkExp = Application.Explorers.Add(OpenOutlookFolder(olkMsg.Parent.FolderPath)) olkExp.Display End Sub Function OpenOutlookFolder(strFolderPath As String) As Outlook.MAPIFolder ' Purpose: Opens an Outlook folder from a folder path.' ' Written: 4/24/2009' ' Author: BlueDevilFan' ' Outlook: All versions' Dim arrFolders As Variant, _ varFolder As Variant, _ bolBeyondRoot As Boolean On Error Resume Next If strFolderPath = "" Then Set OpenOutlookFolder = Nothing Else Do While Left(strFolderPath, 1) = "\" strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1) Loop arrFolders = Split(strFolderPath, "\") For Each varFolder In arrFolders Select Case bolBeyondRoot Case False Set OpenOutlookFolder = Outlook.Session.Folders(varFolder) bolBeyondRoot = True Case True Set OpenOutlookFolder = OpenOutlookFolder.Folders(varFolder) End Select If Err.Number <> 0 Then Set OpenOutlookFolder = Nothing Exit For End If Next End If On Error GoTo 0 End Function
I tried (amateur) following your instructions to create a pop-up for “are you sure you want to send with address…”. I really couls use this on my Outlook 2003. At first run I received a window defining an error I didn’t understand and a chance (I think) to correct it on the fly. Then I thought I would delete and try again, but there’s no delete or erase option that I see. The original code is still there, but no function and no error. Thanks in advance for any tips to someone who blindly followed steps but doesn’t get it. Dean