Last reviewed on May 8, 2014   —  8 Comments

When you use a VBA macro to save messages or files you can hard code the file path, use the user account's My Documents folder, or select a folder on the hard drive. The first two methods are fairly short and sweet.

Note: this function will work in any Office application, it is not specific to Outlook. (Actually, it's not specific to Office either, it's a general VB function.)

Dim strFolderpath  as String
strFolderpath = "C:\OLAttachments\"

Or use this to save to a folder using the user's profile in the path (example, C:\Users\Diane\)

Dim enviro As String
enviro = CStr(Environ("USERPROFILE"))
strFolderpath = enviro & "\OLAttachments\"

For more examples, see Using Windows environment variables in Outlook macros

If you want to bring up a folder picker dialog, you need to use a function, such as the one below.

Browse for a folder to save files toAdd the function to your project and call the folderpath using the following format. You can use any valid file path, either a drive letter or network path (\\). If the path is not valid, the folder picker will show all folders (desktop level), as seen in the screenshot.

strFolderpath = BrowseForFolder("C:\Users\username\documents\")

Use this to save the file:
strFile = strFolderpath & "\" & strFile

(The lines above can be used in Save Attachments to the hard drive)

BrowseForFolder Function

Function BrowseForFolder(Optional OpenAt As Variant) As Variant
  Dim ShellApp As Object
  Set ShellApp = CreateObject("Shell.Application"). _
 BrowseForFolder(0, "Please choose a folder", 0, OpenAt)
 On Error Resume Next
    BrowseForFolder = ShellApp.self.Path
 On Error GoTo 0
 Set ShellApp = Nothing
    Select Case Mid(BrowseForFolder, 2, 1)
        Case Is = ":"
            If Left(BrowseForFolder, 1) = ":" Then GoTo Invalid
        Case Is = "\"
            If Not Left(BrowseForFolder, 1) = "\" Then GoTo Invalid
        Case Else
            GoTo Invalid
    End Select
 Exit Function
 BrowseForFolder = False
End Function


  1. ABE says

    i am sorry on Microsoft outlook 2010 i am using window 7
    i need to create a Macro
    just need to say ( GOT IT )
    not computer savy still need screen shot or some one to walk me step by step

  2. Izbi says

    Is there any way to remember the last filepath so that you don't have to browse through multiple folders again. This is because I want to save emails individually.

    • Diane PoremskyDiane Poremsky says

      To the best of my knowledge, no, you can't remember the last path, at least not with this simple code. I'm sure more complex code could do it, but I don't have any code samples.

  3. Sudhansu says

    Hi Diane, It was so nice of you for sharing pick a folder code for Outlook. It made my job much simpler and quick. Many thnx again. I need one more advise on saving mail to same pick up folder. in above code mail is saved in one up folder.

  4. Hiro says

    Hi Diane,
    Your website is great, incredibly useful!! Thanks.

    Can we get "Save as" instead of having "Browse For Folder",? If we can get "Save as", we can copy and paste the target folder path into "file name" and can get destination folder easier (to me), otherwise I need to navigate the folder.

    Sorry but I don't have good macro knowledge, so if you help me, super appreciated.


Leave a Reply

Please post long or more complicated questions at OutlookForums by

If the Post Comment button disappears, press your Tab key.