문제

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top