How to retrieve Word's default Documents path or Pictures path setting

Article contributed by Bill Coan Bill Coan and Dave Rado

You cannot use:

myDocPath = Options.DefaultFilePath (wdDocumentsPath)

to get the default document path, because this returns the current FileOpen path, not the default documents path!!

Instead, use:

Dim myDocPath As String
myDocPath = Dialogs(wdDialogToolsOptionsFileLocations).Setting

'Add a "\" at the end of the path, unless the setting is already followed by a "\" -
'which it will be if the setting is set to a root folder

If Not Right$(myDocPath, 1) = "\" Then
    myDocPath = myDocPath + "\"
End If

MsgBox myDocPath

Similarly, you cannot use:

myPicPath = Options.DefaultFilePath(wdPicturesPath)

... because if the user has inserted a picture from a different folder, the Default File Path returns that folder rather than the actual setting from the dialog box. Instead, you can use:

With Dialogs(wdDialogToolsOptionsFileLocations)
    .Path = "PICTURE-PATH"
    myPicPath = .Setting

    If Not Right$(myPicPath, 1) = "\" Then
        myPicPath = myPicPath + "\"
    End If

    MsgBox myPicPath 
End With

See also: Getting help with calling Word's built-in dialogs using VBA (and why doing so can be much more useful than you'd think).

Click to view Terms of Use page

Click to view Disclaimer page