GetSaveFileName Function

Creates a dialog box, allowing the user to chose a drive, directory and file name and returns a FixStr value containing full path to the file.

Syntax

GetSaveFileName([extention][,extentionInfo][,title][,defaultFile][,readonlyFlag])

The GetSaveFileName function syntax has these arguments:

Part Description
extention Optional; Variant (String). File extentions separated with (|).
extentionInfo Optional; Variant (String). Describes extentions, specified in extention. Elements in extentionInfo are separated with (|).
title Optional. String expression, displayed in the title bar of the dialog box. If you omit title, the application name is placed in the title bar.
defaultFile Optional. String expression displayed in the edit line of the dialog box. Specifies a filename suggested by default.
readonlyFlag

Optional; Boolean. If the file chosen by the user in the dialog box is read-only, and the readonlyFlag is True, a warning is displayed and the user is asked to choose another file name. If readonlyFlag is False, no warning will be displayed and the function will return the path to the specified file. The default value of this argument is False.

Example

This example uses GetSaveFileName to call a the dialog box and write a string to the selected file.

Dim  Path, n, Check
Path = GetSaveFileName("cdb|txt", "CD Basic|Text Format", "MyTitle", "example1.cdb", True)
Check = StrComp(Path, "")
If Check = 0 Then MsgBox("No file is chosen")
Else
  n = FreeFile()
  Open Path For Output As #n
  Print #n,"some text"
  Close #n
EndIf

 

See Also

GetOpenFileName