FileDialogFilters.Add Method

Adds a new file filter to the list of filters in the Files of type list box in the File dialog box, and returns a FileDialogFilter object that represents the newly added file filter.

Namespace:  Microsoft.Office.Core
Assembly:  office (in office.dll)

Syntax

'Declaration
Function Add ( _
    Description As String, _
    Extensions As String, _
    Position As Object _
) As FileDialogFilter
'Usage
Dim instance As FileDialogFilters
Dim Description As String
Dim Extensions As String
Dim Position As Object
Dim returnValue As FileDialogFilter

returnValue = instance.Add(Description, _
    Extensions, Position)
FileDialogFilter Add(
    string Description,
    string Extensions,
    Object Position
)

Parameters

  • Description
    Type: System.String

    Required String. The text representing the description of the file extension you want to add to the list of filters.

  • Extensions
    Type: System.String

    Required String. The text representing the file 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 Extensions argument can be assigned to the string: "*.txt; *.htm".

    Note Parentheses do not need to be added around the extensions. Office will automatically add parentheses around the extensions string when the description and extensions strings are concatenated into one file filter item.

  • Position
    Type: System.Object

    Optional Object. 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.

Return Value

Type: Microsoft.Office.Core.FileDialogFilter

Remarks

Each filter in a list is made up of two parts: the file extension (e.g. .txt) and the text description of the file extension (e.g. Text Files). Together, the file filter would appear in the Files of type list box 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 runtime error is displayed. If the Description and Extensions values are invalid, a runtime error (parse) is displayed.

Folder picker dialogs do not have filters. Therefore, filter methods do not apply to the folder picker.

See Also

Reference

FileDialogFilters Interface

FileDialogFilters Members

Microsoft.Office.Core Namespace