Type mismatch in SaveAs method

mae0429

Board Regular
Joined
Jun 12, 2008
Messages
114
Hello everyone, I keep getting a type mismatch when I try to run this, saving it as something different than it currently is named:


Code:
msb3 = MsgBox("Would you like to save the updated file, prior to sheet-splitting?", vbYesNo, "Save updates?")
If msb3 = vbYes Then
    fileSaveName = Application.GetSaveAsFilename(FileFilter:="Excel Files (*.xls), *.xls")
    If fileSaveName <> False Then
        ThisWorkbook.SaveAs Filename:=fileSaveName
    End If
End If

Any reason this shouldn't work?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

If you've defined fileSaveName as anything other than a variant (or boolean, which would make no sense) then you will get a type mismatch as a string can't equal False (hence the mismatch). Dim it as a Variant and the code should work.
 
Upvote 0

Forum statistics

Threads
1,190,743
Messages
5,982,703
Members
439,790
Latest member
jonaust

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top