FileDialogFilters.Add method (Office)

Adds a new file filter to the list of filters in the Files of type drop-down list in the File dialog box. Returns a FileDialogFilter object that represents the newly added file filter.

Syntax

expression.Add (Description, Extensions, Position)

expression Required. A variable that represents a FileDialogFilters object.

Parameters

Name Required/Optional Data type Description
Description Required String The text representing the description of the file name extension that you want to add to the list of filters.
Extensions Required String The text representing the file name extension you want to add to the list of filters. More than one extension may be specified, and each must be separated by a semi-colon. For example, the argument can be assigned to the string: "*.txt; *.htm".

NOTE: Parentheses don't need to be added around the extensions. Microsoft Office will automatically add parentheses around the extensions string when the description and extensions strings are concatenated into one file filter item.
Position Optional Variant A number that indicates the position of the new control in the filter list. The new filter will be inserted before the filter at this position. If this argument is omitted, the filter is added at the end of the list.

Remarks

Each filter in a list is made up of two parts: the file name extension (that is, .txt) and the text description of the file name extension (that is, Text Files). Together, the file filter would appear in the Files of type list as: Text Files (*.txt).

Note that when a filter is added to the list, the default filters are not removed. Filters are only displayed when the Windows option is checked. If Position is invalid, an out-of-range run-time error is displayed. If the Description and Extensions values are invalid, a run-time error (parse) is displayed.

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.