Example

This example displays a box that lists either settings or text files. Because 2 is given as the value for FileIndex, text files (the second file filter) are listed by default. The dialog box is given the title "Setting and Text Files." No value is given for ButtonText, so the default is used.

In this example, the file selected by the user is displayed in a message box.

The underscore character is used to divide the long line. Without this character, the first argument could be given as:

"Settings Files (*.rsf), *.rsf, Text Files (*.txt), *.txt"

Sub OpenFileDemo ()

 With Session

  Dim sesame As String

  sesame = .GetOpenFilename("Settings Files (*.rsf), *.rsf," & _

     "Text Files (*.txt), *.txt", 2, _

     "Setting and Text Files")

  MsgBox sesame

 End With

End Sub