CoNS
02-23-2017, 01:38 AM
Hi, I hope one of you can help me with this macro:
Public Sub GetItemsFolderPath()
Dim obj As Object
Dim F As Outlook.MAPIFolder
Dim Msg$
Set obj = Application.ActiveWindow
If TypeOf obj Is Outlook.Inspector Then
Set obj = obj.CurrentItem
Else
Set obj = obj.Selection(1)
End If
Set F = obj.Parent
Msg = "The path is: " & F.FolderPath & vbCrLf
Msg = Msg & "Switch to the folder?"
If MsgBox(Msg, vbYesNo) = vbYes Then
Set Application.ActiveExplorer.CurrentFolder = F
End If
End Sub
I use it when having done a search in Outlook 2016 and having selected the relevant email from the search results, to jump to the exact (sub)folder containing that email and for this purpose the macro works very well.
However, I would like to add to the macro so that it not only jumps to the correct folder but also selects the very same email that I had originally selected (from the search results). Currently the macro just jumps to the folder and selects the first email in the folder.
Furthermore, while I mainly use the macro after having done a search, there are some situations, where I would also like to use the macro when selecting an email from a "Favorites" folder (displayed in the "Favorites" section in the navigation pane). I.e. I have added a subfolder from way down in a folder hierarchy to my "Favorites" and after selecting that folder in the "Favorites" view and then selecting an email therein I would like to be able to jump to the folder with the whole path open. Currently, the macro does show the correct path in the message box, but in the second part it does nothing (it does not make the jump).
Thank you in advance for your kind assistance. Much appreciated. :type
Public Sub GetItemsFolderPath()
Dim obj As Object
Dim F As Outlook.MAPIFolder
Dim Msg$
Set obj = Application.ActiveWindow
If TypeOf obj Is Outlook.Inspector Then
Set obj = obj.CurrentItem
Else
Set obj = obj.Selection(1)
End If
Set F = obj.Parent
Msg = "The path is: " & F.FolderPath & vbCrLf
Msg = Msg & "Switch to the folder?"
If MsgBox(Msg, vbYesNo) = vbYes Then
Set Application.ActiveExplorer.CurrentFolder = F
End If
End Sub
I use it when having done a search in Outlook 2016 and having selected the relevant email from the search results, to jump to the exact (sub)folder containing that email and for this purpose the macro works very well.
However, I would like to add to the macro so that it not only jumps to the correct folder but also selects the very same email that I had originally selected (from the search results). Currently the macro just jumps to the folder and selects the first email in the folder.
Furthermore, while I mainly use the macro after having done a search, there are some situations, where I would also like to use the macro when selecting an email from a "Favorites" folder (displayed in the "Favorites" section in the navigation pane). I.e. I have added a subfolder from way down in a folder hierarchy to my "Favorites" and after selecting that folder in the "Favorites" view and then selecting an email therein I would like to be able to jump to the folder with the whole path open. Currently, the macro does show the correct path in the message box, but in the second part it does nothing (it does not make the jump).
Thank you in advance for your kind assistance. Much appreciated. :type