Display dialogue to allow a user to select an Outlook folder in VBA
-
12-12-2019 - |
문제
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
제휴하지 않습니다 StackOverflow