Prompt User to Save File with Specific Extension (xlsm)


New Member
Dec 18, 2017
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!!


Well-known Member
Feb 7, 2012
Office Version
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.
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
(FileFilter:="Excel Files(*.xlsm), *.xlsm")
Last edited:

Forum statistics

Latest member
Joaquin Phoenix

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...