I've written some Outlook VBA which needs the user to select a mail folder (either from within their mailbox or from within an external PST).
At the moment, they have to edit the path directly within the code - which is not remotely user friendly or efficient.
Does anyone know how to get a dialogue box to appear that allows the user to browse all available folders and sub-folders and select one?
Bonus points if it can be limited to mail folders only but it's not essential.
Try using the Pickfolder method:
Sub FolderPick()
Dim objNS As NameSpace
Dim objFolder As folder
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder
If TypeName(objFolder) <> "Nothing" Then
Debug.Print vbCr & " objFolder: " & objFolder
Else
Debug.Print vbCr & "Cancel"
End If
Set objFolder = Nothing
Set objNS = Nothing
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With