문제

Is there a way (code) for "Save As" dialog in Word VBA with customer filters? For example: ".ttt"

도움이 되었습니까?

해결책

I think you probably want to use the Application.FileDialog as this allows custom file filters. As KazJaw points out you can't save a Photoshop file in Word so I assume its to allow some other manipulation of a psd file.

The following shows you how to use it (see http://msdn.microsoft.com/en-us/library/aa219843%28office.11%29.aspx). Note this will allow the user to select multiple files though.

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top