Save As Macro Enabled Workbook

CC268

Active Member
Joined
Mar 7, 2016
Messages
328
Hey guys,

I would like to create a VBA code that simply opens the Save As dialog window (in order to type your desired file name) and saves it as a Macro Enabled Workbook.

Thanks
 
Why do you need the pop-up window? You could save it directly since you're using the Activeworkbook's full name:
Code:
Dim fName As String

fName = ActiveWorkbook.FullName & "_" & Format(today, "DD-MM-YYYY") & ".xlsm"

' FileSaveName = Application.GetSaveAsFilename(InitialFileName:=fName, filefilter:="Excel Files(*.xlsm),*.xlsm", Title:="Please save the file")
' If FileSaveName <> False Then ActiveWorkbook.SaveAs FileName:=fName, FileFormat:=52

ActiveWorkbook.SaveAs FileName:=fName, FileFormat:=52

I don't, but I would like the user to be able to choose the filename they want. But being able to start with the current file name + date added to the end is a nice place to start.
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try:
Code:
Dim tDate As String
Dim FileSaveName As String
Dim fName As String

fName = ActiveWorkbook.FullName & "_" & Format(today, "DD-MM-YYYY")
FileSaveName = Application.GetSaveAsFilename(InitialFileName:=fName, filefilter:="Excel Files(*.xlsm),*.xlsm", Title:="Please save the file")
If len(FileSaveName) > 0 Then ActiveWorkbook.SaveAs FileName:=fName, FileFormat:=52
 
Last edited:
Upvote 0
Try this
Code:
Application.Dialogs(xlDialogSaveAs).Show , xlOpenXMLWorkbookMacroEnabled
 
Last edited:
Upvote 0
Try:
Code:
Dim tDate As String
Dim FileSaveName As String
Dim fName As String

fName = ActiveWorkbook.FullName & "_" & Format(today, "DD-MM-YYYY")
FileSaveName = Application.GetSaveAsFilename(InitialFileName:=fName, filefilter:="Excel Files(*.xlsm),*.xlsm", Title:="Please save the file")
If len(FileSaveName) > 0 Then ActiveWorkbook.SaveAs FileName:=fName, FileFormat:=52

Unfortunately again:

1. No file name shows up in the save as box - have to type your own name
2. If you press the cancel button it still saves the file.

Mike's solution below works, but would like to get it to pre-populate the save as dialog box with the current file name.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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