FileDialog Filters.clear

E

eggpap

I have the following "classical" code to use a filedialog control in Excel
2003:

Function FileSelector(tipo As Integer)
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogSaveAs)

Dim vrtSelectedItem As Variant

With fd
.Filters.Clear
.Filters.Add "MyCustomFiles", "*.trn"

If .Show = -1 Then

For Each vrtSelectedItem In .SelectedItems
FileSelector = vrtSelectedItem
Next vrtSelectedItem
Else
End If
End With
Set fd = Nothing

End Function

It performs correctly without the .Filters statements. With them, instead, I
get the following error:

Property or method not supported by the object

I use Excel 2003/SP3

Any help?

Thanks
 
J

Joel

Why don't you justt use GetSaveAsFileName???

Sub FileSelector()
Dim fileSaveName As String
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="MyCustomfiles (*.trn), *.trn")
If fileSaveName <> False Then
MsgBox "Save as " & fileSaveName
FileSelector = fileSaveName
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top