PathMustExist

Returns or sets whether the Open and Save As dialogs accept only paths that exist.

Syntax: object.PathMustExist [ = boolean ]

object
required An object expression that evaluates to a cDialog.
boolean
A Boolean. True sets OFN_PATHMUSTEXIST. The default is True.

Remarks

ShowOpen and ShowSave use the property. With True, a path that the user types and that does not exist makes Windows show a warning in a message box, and the dialog stays open. ShowBrowseForFolder ignores the property.

In an Open dialog, FileMustExist True sets OFN_FILEMUSTEXIST, which Windows documents as implying OFN_PATHMUSTEXIST. ShowOpen with FileMustExist True therefore checks the path whatever PathMustExist holds.

Example

Dim dlg As New cDialog
Debug.Print dlg.PathMustExist   ' True

dlg.PathMustExist = False
Debug.Print dlg.PathMustExist   ' False

This example lets the Save As dialog accept a name in a folder that does not exist yet.

Dim dlg As New cDialog
Dim path As String

dlg.PathMustExist = False
path = dlg.ShowSave()
If Len(path) > 0 Then
    Debug.Print "Chosen: " & path
End If

See Also