Prompt User to Save File with Specific Extension (xlsm)

Orion19

Board Regular
Joined
Dec 18, 2017
Messages
56
Hello you amazingly helpful Excel wizards!

I have a csv file that I'm fixing up using VBA. I'm getting errors about running out of memory and have read that saving the file can help resolve that. I'd like to prompt the user to save the file immediately after the macro is ran but can't seem to get it right. I can open the dialogue box using Application.GetSaveAsFilename but I want to force the user to pick the Macro Enabled Workbook extension (xlsm). Is there a way to go about doing this? There will be multiple users using different computers so the file path can't be determined ahead of time.

Thanks in advance!!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
In your macro, when you call the SaveAs dialog box you can specify the type of file extension. If the user puts a different file extension on, it will just become part of the file name and the .xlsm will still be the prevailing file extension.
Code:
fName = Application.GetSaveAsFilename(Filename, "Excel Files(*.xlsm), *.xlsm")
ActiveWorkbook.SaveAs fName

Just give them instructions to not put a file extension on at all. Let VBA do it for you.

P.S. the 'filename' you see in the code is a place holder only. You can substitute a proposed file name in Quotes , or leave it blank. If you leave it blank, you will still need to put the comma in to avoid an error message, since VBA is expecting a string there. If you don't use the comma then you have to
Code:
(FileFilter:="Excel Files(*.xlsm), *.xlsm")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,785
Messages
6,121,543
Members
449,038
Latest member
Guest1337

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