FileName$()

Syntax

FileName$([Number])

Remarks

Returns the path and filename of the active document or of a file in the list of recently used files at the bottom of the File menu.

Argument

Explanation

Number

The number of the file in the order listed on the File menu, from 1 through 9. If the number is 0 (zero) or omitted, FileName$() returns the name of the active document; if there is no active document, it returns an empty string(""). If Number is greater than the number of files listed on the File menu, an error occurs.

You can control the number of filenames that appear on the File menu with the Recently Used File List option on the General tab in the Options dialog box (Tools menu).


Example

When run, this example demonstrates the difference between FileName$() and WindowName$(). FileName$() always returns a file's path and filename. WindowName$() returns the window title, which does not include the path and may include extra text such as "(Read-Only)" or ":2" after the filename.


MsgBox "File = " + FileName$() + Chr$(13) + \
    "Window = " + WindowName$()

See Also

CountFiles(), FileList, FileNameFromWindow$(), FileNumber, Files$(), WindowName$()