Sub XXX () dim Arr () Arr = application. getopenfilename ("all payment files (*. XLS ;*. XLSX ;*. CSV ),*. XLS ;*. XLSX ;*. CSV, Excel file (*. XLS ),*. xls, excel2007 file (*. XLSX ),*. XLSX, CSV file (*. CSV ),*. CSV "," select file ", true) for I = lbound (ARR) to ubound (ARR) cells (I, 1 ). value = Arr (I) nextend sub
In the preceding example, select multiple files.
The following is the original Microsoft text
Application. getopenfilename Method |
Display standard"Open"Dialog box, and get the user file name, without actually opening any file.
Syntax
Expression. Getopenfilename (Filefilter,
Filterindex,Title,Buttontext,Multiselect)
ExpressionOne representativeApplicationObject variable.
Parameters
Name |
Required/optional |
Data Type |
Description |
Filefilter |
Optional |
Variant |
A string that specifies the file filtering conditions. |
Filterindex |
Optional |
Variant |
Specifies the index number of the default file filtering conditions. The value ranges from 1FilefilterThe number of specified filtering conditions. If this parameter is omitted, or the value of this parameter is greater than the number of available filtering conditions, the first file filtering condition is used. |
Title |
Optional |
Variant |
Specify the title of the dialog box. If this parameter is omitted, the title is "open ". |
Buttontext |
Optional |
Variant |
Only for Macintosh. |
Multiselect |
Optional |
Variant |
IfTrueYou can select multiple file names. IfFalseOnly one file name can be selected. The default value is False. |
Return Value
Variant
Description
InFilefilterThe string passed in the parameter is composed of a file filter string pair and a MS-DOS wildcard file filter followed by a comma separated. Each string is in"File type"It is listed in the drop-down list box. For example, the following string specifies two file filtering-text and macro loading: "text file (*. TXT ),*. TXT: loads the macro file (*. xla ),*. xla ".
To use multiple MS-DOS wildcard expressions for a single file filter type, separate them with semicolons. For example, "Visual Basic file (*. Bas; *. txt), *. Bas; *. txt ".
If omittedFilefilterThe default value of this parameter is "all files (*.*),*.*".
This method returns the selected file name or the name entered by the user. The returned name may contain the path description. IfMultiselectIsTrueThe returned value is an array containing all selected file names (even if only one file name is selected ). If the user cancels the dialog box, the value is
False.
This method may change the current drive or folder.