Extensions 属性


返回一个 String 类型,包含决定每个 Filter 对象在文件对话框中显示的文件扩展名。只读。


expression   必需。该表达式返回“应用于”列表中的对象之一。


本示例在“另存为”对话框的默认筛选中迭代,并显示每个包括 Microsoft Excel 文件的筛选说明。Extensions 属性用于查找相应的筛选对象。

Sub Main()

    'Declare a variable as a FileDialogFilters collection.
    Dim fdfs As FileDialogFilters

    'Declare a variable as a FileDialogFilter object.
    Dim fdf As FileDialogFilter

    'Set the FileDialogFilters collection variable to
    'the FileDialogFilters collection of the SaveAs dialog box.
    Set fdfs = Application.FileDialog(msoFileDialogSaveAs).Filters

    'Iterate through the description and extensions of each
    'default filter in the SaveAs dialog box.
    For Each fdf In fdfs

        'Display the description of filters that include
        'Microsoft Excel files.
        If InStr(1, fdf.Extensions, "xls", vbTextCompare) > 0 Then
            MsgBox "Description of filter: " & fdf.Description
        End If
    Next fdf
End Sub