Pergunta

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.

Foi útil?

Solução

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top