1

Word VBA中带有客户过滤器的“另存为”对话框是否有方法(代码)?例如:“.ttt”

4

1 回答 1

4

我认为您可能想要使用它,Application.FileDialog因为它允许自定义文件过滤器。正如 KazJaw 指出的那样,您无法在 Word 中保存 Photoshop 文件,因此我认为它允许对psd文件进行其他一些操作。

下面向您展示如何使用它(参见http://msdn.microsoft.com/en-us/library/aa219843%28office.11 ​​%29.aspx )。请注意,这将允许用户选择多个文件。

Sub CustomFilter()
    'Declare a variable for the FileDialog object and one for the selectedItems
    Dim fd As FileDialog, vSelectedItem As Variant

    'Create a FileDialog object as a File Picker dialog box.
    Set fd = Application.FileDialog(msoFileDialogFilePicker)

    'With the FileDialog
    With fd
        .Filters.Clear                              'Clear current filters
        .Filters.Add "Photoshop Files", "*.psd", 1  'Add a filter that has Photoshop Files.

        If .Show = -1 Then
            'Step through each String in the FileDialogSelectedItems collection.
            For Each vSelectedItem In .SelectedItems
                'Do whatever you want here
            Next vSelectedItem
        Else
            'The user pressed Cancel.
        End If
    End With

    Set fd = Nothing
End Sub
于 2013-06-20T00:47:28.307 回答