FileFind

Syntax

FileFind [.SearchName = text] [, .SearchPath = text] [, .Name = text] [, .SubDir = number] [, .Title = text] [, .Author = text] [, .Keywords = text] [, .Subject = text] [, .Options = number] [, .MatchCase = number] [, .Text = text] [, .PatternMatch = text] [, .DateSavedFrom = text] [, .DateSavedTo = text] [, .SavedBy = text] [, .DateCreatedFrom = text] [, .DateCreatedTo = text] [, .View = number] [, .SortBy = number] [, .ListBy = number] [, .SelectedFile = number] [, .ShowFolders = number] [, .Add] [, .Delete]

Remarks

Creates a list of files based on the search criteria specified by one or more of the arguments. In Word version 6.0, the arguments for the FileFind statement correspond to the options in the Search dialog box (Find File command, File menu).

In Word version 7.0, the .SearchName, .Options, .PatternMatch, .View, .SortBy, .ListBy, .SelectedFile, .ShowFolders, .Add, and .Delete arguments are ignored, and you cannot use a Dialog or Dialog() instruction to display the Word version 6.0 Find File dialog box.

Argument

Explanation

.SearchName

A name given to a group of search criteria you want to add to or remove from the Search dialog box (using .Add or .Delete). Note that when performing the search, Word ignores .SearchName; you must specify criteria using .SearchPath, .Name, and so on.

.SearchPath

A path or list of paths in which to search for files. In Word version 6.0, you can specify more than one path by separating them with semicolons (;). In Word version 7.0, you cannot specify more than one path.

.Name

The name of the document or, in Windows, a file specification. To find document templates, for example, the file specification would be "*.DOT". On the Macintosh, use MacID$() to specify a file type (for example, MacID$("WTBN") to find document templates).

.SubDir

If 1, Word searches subfolders of the folder or folders specified by .SearchPath.

.Title

Title in the Summary Info dialog box

.Author

Author in the Summary Info dialog box

.Keywords

Keywords used to identify the document in the Summary Info dialog box

.Subject

Subject in the Summary Info dialog box

.Options

Specifies how to list the found files:

0 (zero) Create a new list

1 Add matches to the existing file list

2 Search only in the existing file list

.MatchCase

Specifies whether to match the case of each letter in .Text:

0 (zero) Do not match the case (default)

1 Match the case

.Text

The text to search for in the document

.PatternMatch

If 1, Word evaluates .Text as a string containing advanced search criteria such as the asterisk (*) and question mark (?) wildcard characters. For more information, search for "search operators" in Word Help and choose "Advanced search criteria."

.DateSavedFrom

The document save date you want to search from

.DateSavedTo

The document save date you want to search to

.SavedBy

The name of the person who last saved the document


Argument

Explanation

.DateCreatedFrom

The document creation date you want to search from. The following are examples of valid date formats:

7/8/93

8-Jul-91

July 8, 1991

.DateCreatedTo

The document creation date you want to search to

.View

Specifies what to display on the right side of the dialog box when you display the Find File dialog box with a Dialog or Dialog() instruction:

0 (zero) File information (a line for each file)

1 A preview window of the contents of the selected file

2 Summary information for the selected file

.SortBy

Specifies how documents are sorted when you display the Find File dialog box with a Dialog or Dialog() instruction:

0 (zero) Alphabetically by author

1 By creation date, with the most recently created file listed first

2 Alphabetically by the name of the person who last saved the document

3 By the date last saved, with the most recently saved file listed first

4 Alphabetically by filename

5 By size, with the smallest file listed first

.ListBy

Specifies whether to list filenames or titles on the left side of the dialog box when you display the Find File dialog box with a Dialog or Dialog() instruction:

0 (zero) Filenames

1 Titles

.SelectedFile

When you've used a Dialog or Dialog() instruction to display the Find File dialog box, returns a number when the user closes the dialog box that corresponds to the file that was last selected. To retrieve the filename, pass this value to the FoundFileName$() function (for example, FoundFileName$(dlg.SelectedFile)).

.ShowFolders

If 1, groups filenames by folder when you display the Find File dialog box with a Dialog or Dialog() instruction.

.Add

Stores the specified search criteria under the name specified by .SearchName; may be used to create or modify a group of search criteria.

.Delete

Removes the group of search criteria specified by .SearchName.


If you specify multiple words for .Title, .Subject, .Author, .Keywords, .Path, and .Text, Word interprets the entire argument as a logical expression rather than as a multiple-word phrase. A comma serves as the logical operator OR, and a space or an ampersand (&) serves as the logical operator AND.

Examples

This Windows example searches a folder for files with the .RPT filename extension, defines an array to hold their names, and then uses FoundFileName$() to fill the array with the filenames.


FileFind .SearchPath = "C:\REPORTS", .Name = "*.RPT"
size = CountFoundFiles() - 1
If size >= 0 Then
    Dim mydocs$(size)
    For count = 0 To size
        mydocs$(count) = FoundFileName$(count + 1)
    Next
End If

The following Macintosh example creates a dialog record for the Find File dialog box, sets the search path and file type criteria, specifies that summary information be displayed for the found files, and then displays the list of found files.


Dim dlg As FileFind
dlg.SearchPath = "HD:MY DOCUMENTS"
dlg.Name = MacID$("W6BN")
dlg.View = 2
x = Dialog(dlg)

See Also

CountFoundFiles(), FoundFileName$()