Link to home
Start Free TrialLog in
Avatar of rogerdjr
rogerdjrFlag for United States of America

asked on

Outlook File Picker default path

In outlook I use this code to select a folder

Would like to set it as a prompt Yes/No that if I click yes it selects the folder Drafts\Process Eblast and if i hit no it goes to the file picker

    MsgBox "Select Email Folder Recommend Drafts\Process Eblast\"
    Set ofldr = Session.PickFolder

Minor issue but would be a great time saver

Thanks
Avatar of Bill Prew
Bill Prew

If I understand correctly, you could try something like this.  It asks if you want to use the default folder, and if so does not show the picker, but uses the default you want.

    Dim Result As Integer
    Dim ofldr As Folder
    
    useDefault = MsgBox("Use default Email Folder ""Drafts\Process Eblast""", vbYesNo)
    
    If useDefault = vbYes Then
        With Outlook.GetNamespace("MAPI")
            Set ofldr = .Folders("Drafts").Folders("Process Eblast")
        End With
    Else
        Set ofldr = Session.PickFolder
    End If
    
    Debug.Print ofldr.Name

Open in new window


»bp
Avatar of rogerdjr

ASKER

Tried to run the code get an error message

Run-time error '·21472212J3 (800'10101)':
The attempted operation failed, An object could not be found.


See attached images - file structure and error message
2019-10-15-error-message---file-Stru.pdf
What platform are you developing in, I took your question to be a VBA question.

And I would normally expect to see an account node in the default folder path:

Set ofldr = .Folders("Drafts").Folders("Process Eblast")


»bp
Used             Set ofldr = GetFolderPath("\\roger@eaglepromanagement.com\Drafts\Process Eblast Emails")

and it works

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial