SaveAs Dialog Box with Custom Filename and .xlsx extension

bigmacfann

New Member
Joined
Aug 26, 2005
Messages
44
Hello, I have been working on a macro to save a file with a custom filename but I can't seem to find a way to put the .xlsx extension on the end of the filename.

Code:
Dim sFile As String
     sFile = Application.GetSaveAsFilename("RFI " & Range("G5").Text)

If I have "120" in cell G5, ideally, the filename will be "RFI 120.xlsx" but currently all that shows up is "RFI 120" and I do not have the option to select .xlsx in the 'Save As Type' drop down. Any help would be greatly appreciated! Thank you.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hello, I have been working on a macro to save a file with a custom filename but I can't seem to find a way to put the .xlsx extension on the end of the filename.

Code:
Dim sFile As String
     sFile = Application.GetSaveAsFilename("RFI " & Range("G5").Text)

If I have "120" in cell G5, ideally, the filename will be "RFI 120.xlsx" but currently all that shows up is "RFI 120" and I do not have the option to select .xlsx in the 'Save As Type' drop down. Any help would be greatly appreciated! Thank you.


Here is one way (although my VBA is limited I am sure some one knows a better way
Code:
Sub Save_me()
Dim sFile As String
     sFile = ("RFI " & Range("G5").Text)
 
 ActiveWorkbook.SaveAs Filename:=sFile, FileFormat:=xlOpenXMLWorkbookMacroEnabled
   
   
End Sub
 
Upvote 0
MDuff,

Thank you for your reply. Unfortunately, the line of code provided did not add .xlsx to the end of the custom filename. Also, if the user clicks 'Cancel', it automatically saved the file as 'False.xlsx'

I should mention that in addition to adding the extension .xlsx to the end of the custom filename, I would like the user to have the ability to specify which folder to save the file in.

This piece of code is at the end of a macro which takes data from all over another workbook and adds it to a new workbook called 'RFI_Temp.xlsx'. If the user clicks 'Cancel', I would like the filename to remain as RFI_Temp.xlsx and not save. Thank you everyone in advance!
 
Upvote 0

Forum statistics

Threads
1,222,561
Messages
6,166,802
Members
452,073
Latest member
akinch

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