Syntax 

GetFilePath[$]([DefName$], [DefExt$], [DefDir$], [Title$], [Option])


Group 

User Input 


Description 

Put up a dialog box and get a file path from the user. The returned string is a complete path and file name. If the cancel button is pressed then a null string is returned.


Parameters

Description

DefName$ 

Set the initial File Name in the to this string value. If this is omitted then *.DefExt$ is used.

DefExt$ 

Initially show files whose extension matches this string value. (Multiple extensions can be specified by using ";" as the separator.) If this is omitted then * is used.

A "filter" may be specified using "description|*.ext|". Multiple descriptions can be used by repeating this format. (e.g. "Bitmap files|*.bmp|PNG files|*.png|JPEG files|*.jpg")

DefDir$ 

This string value is the initial directory. If this is omitted then the current directory is used.

Title$ 

This string value is the title of the dialog. If this is omitted then "Get File Path" is used.

Option 

This numeric value determines the file selection options. If this is omitted then zero is used. See table below.


Option

Effect

0

Only allow the user to select a file that exists.

1

Confirm creation when the user selects a file that does not exist.

2

Allow the user to select any file whether it exists or not.

3

Confirm overwrite when the user selects a file that exists.

4

Only allow the user to select a file that exists. Selecting a different directory changes the application's current directory.

5

Confirm creation when the user selects a file that does not exist. Selecting a different directory changes the application's current directory.

6

Allow the user to select any file whether it exists or not. Selecting a different directory changes the application's current directory.

7

Confirm overwrite when the user selects a file that exists. Selecting a different directory changes the application's current directory.

8

User can select multiple files. Files are separated by vbCrLf.

9

User can select multiple files. Files are separated by vbCrLf. Selecting a different directory changes the application's current directory.


Example

Sub Main

    Debug.Print GetFilePath$()

End Sub