Word VBA中的“另存为”对话框是否有方法(代码)与客户过滤器?例如:“.ttt”
答案 0 :(得分: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