GetSaveAsFilename corrupts spreadsheet

LlebKcir

Board Regular
Joined
Oct 8, 2018
Messages
219
Code:
sFName = Application.GetSaveAsFilename(FileFilter:="Excel Files (*.xlsx), *.xlsx, Macro Enabled Workbook" & "(*.xlsm), *xlsm")

    If sFName <> "False" Then
        ws.SaveAs sFName, 56
    End If

With sFName set as a string. I am using MS Office 2016 on win10 if that helps, have not tried this in Office 2010 yet, that will happen later. Laptop is on 2016, VM is on 2010 on win7.

The code works so far as populating a desired file name (that code not shown, just a few text strings placed under: InitialFileName:=Variable_here), but when I click save I am faced with compatibility errors, than after that the file while showing in the correct location is broke and corrupted to the point you must delete, zero access.

This is a major problem, is the GetSaveAsFilename code trying to save as some other file even though xlsx and xlsm are "options" shown?

This happens with both xlsx and xlsm files for this code.
 
Glad we could help & thanks for the feedback
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,213,510
Messages
6,114,044
Members
448,543
Latest member
MartinLarkin

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
Back
Top