Run-time error ‘13’ mismatch type




The following code work fine until I try to added the 7th filefilter. I want
to have 21 different filefilter or 24 filefilter. If I can find out the
FileFormatValue for (*.xml), (*.xlam), and (*.xla).

The question is how to get my code to have more than 6 filefilter without
having a run-time error 13.

My Code

NewFullName = Application.GetSaveAsFilename(InitialFileName:=(MyFullName),
filefilter:= _
" Excel Workbook (*.xlsx), *.xlsx," & _
" Excel Macro-Enabled Workbook (*.xlsm), *.xlsm," & _
" Excel Binary Workbook (*.xlsb), *.xlsb," & _
" Excel 97-2003 Workbook (*.xls), *.xls," & _
" Single File Web Page (*.mht; *.mhtml), *.mht; *.mhtml," & _
" SYLK (Symbolic link) (*.slk), *.slk", _

I still want to add 14 more filefilter between Single file web page and SYLK:

" Web Page (*.htm; *.html), *.htm; *.html," & _
" Excel Template (*.xltx), *.xltx," & _
" Excel Macro-Enabled Template (*.xltm), *.xltm," & _
" Excel 97-2003 Template (*.xlt), *.xlt," & _
" Text (Tab delimited) (*.txt), *.txt," & _
" Unicode Text (*.txt), *.txt," & _
" XML Spreadsheet 2003 (*.xml), *.xml," & _
" Microsoft Excel 5.0/95 Workbook (*.xls), *.xls," & _
" CSV (Comma delimited) (*.csv), *.csv," & _
" Formatted Text (Space delimited) (*.prn), *.prn," & _
" Text (Macintosh) (*.txt), *.txt," & _
" Text (MS-DOS) (*.txt), *.txt," & _
" CSV (Macintosh) (*.csv), *.csv," & _
" CSV (MS-DOS) (*.csv), *.csv," & _
" DIF (Data Interchange Format) (*.dif), *.dif," & _

Thank you



I am not sure that you are on the right track for what you are trying to
achieve. I have given examples of 2 methods you might like to try.

You would normally only have one file filter and that is the one that you
want the user to use for the save. Something like the following adapted from
xl help.

Sub testFileSaveAs()
Dim fileSaveName

fileSaveName = Application.GetSaveAsFilename _
(fileFilter:= _
"Text Files (*.txt), *.txt", _
InitialFileName:="Test Save As")

If fileSaveName <> False Then
MsgBox "Save as " & fileSaveName
MsgBox "User cancelled without saving."
End If
End Sub

If you want the SaveAs dialog box to allow the user to select the file type
then try the following code.

Sub testFileSaveAs1()

Dim diaSaveAs As Dialog

Set diaSaveAs = Application.Dialogs(xlDialogSaveAs)

With diaSaveAs
If .Show Then
MsgBox "File saved as filename: " _
& ThisWorkbook.Name
MsgBox "User cancelled without saving"
End If
End With

End Sub

Hope this helps.

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