Open Containing Folder in Outlook
I got increasingly frustrated in Outlook when after a search I couldn't find the email item I was looking at in its original folder. I could see the folder if I added the column to the search results, but didn't know where that folder was in my directory tree. So if you have more than one "done" folder or something, it can be hard to find.
To solve this (as it was no different in Outlook 2013 and I'd be wanting this for some time) I came up with the following code to
To solve this (as it was no different in Outlook 2013 and I'd be wanting this for some time) I came up with the following code to
- Show the path to the folder
- Open that folder, so that the folder contents can be seen.
In effect, this is an Open Containing Folder for Outlook. Enjoy.
Sub GoToFolder()
Dim loThisEmail As MailItem, loInspector As Inspector
Dim loFolder As Folder
Set loInspector = Application.ActiveInspector
If loInspector Is Nothing Then
MsgBox "No active inspector"
Else
Set loThisEmail = loInspector.CurrentItem
Set loFolder = loThisEmail.Parent
ShowFolderPath loFolder
End If
End Sub
Public Sub ShowFolderPath(toFolder As Folder)
Dim lsPath As String
Dim lsParent As String
Dim loFolder As Folder
Dim lsJoin As String
Dim llContinue As Boolean
lsJoin = ""
lsPath = ""
llContinue = True
Set loFolder = toFolder
Do While llContinue
lsPath = loFolder.Name & lsJoin & lsPath
lsJoin = "-->"
lsParent = ParentPath(loFolder.Parent)
If Len(lsParent) = 0 Then
llContinue = False
Else
Set loFolder = loFolder.Parent
End If
Loop
lsPath = lsPath & vbCrLf & vbCrLf & "Open this folder?"
If MsgBox(lsPath, vbYesNo) = vbYes Then
toFolder.Display
End If
End Sub
Public Function ParentPath(toFolder As Folder) As String
Dim loFolder As Folder
ParentPath = ""
'Bit of a kludge
If toFolder.Parent <> "Mapi" Then
Set loFolder = toFolder.Parent
If IsObject(loFolder) Then
ParentPath = loFolder.Name
End If
End If
End Function
Comments
Post a Comment