Save As Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Guest
I am in the process of recording a macro and would like at the very end for the Save As dialogue box to pop up and allow the user to enter a file name. I pasted the portion of the macro I would like to change below. If anyone knows how I could get rid of the current path and allow the user to create their own every time they the macro is run I would be greatly appreciative.

Thanks
Will

'
Workbooks.Open FileName:="C:findatupEXCEL.CSV"
ActiveWorkbook.SaveAs FileName:="C:findatuptest_change.csv", FileFormat:= _
xlCSV, CreateBackup:=False
ActiveWindow.Close
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Here you go:

Code:
Dim SaveFileName As String
Workbooks.Open FileName:="C:findatupEXCEL.CSV"
SaveFileName = Application.GetSaveAsFilename
ActiveWorkbook.SaveAs FileName:=SaveFileName, FileFormat:= _
xlCSV, CreateBackup:=False
ActiveWindow.Close

Regards,
 
Upvote 0
Barries code will certainly do the trick, all I would add is a line in case they Cancel.

Dim SaveFileName As String
Workbooks.Open Filename:="C:\findatup\EXCEL.CSV"
SaveFileName = Application.GetSaveAsFilename
If SaveFileName = "False" Then Exit Sub 'Cancelled
ActiveWorkbook.SaveAs Filename:=SaveFileName, FileFormat:= _
xlCSV, CreateBackup:=False
ActiveWindow.Close

Or you could use:

Workbooks.Open Filename:="C:\findatup\EXCEL.CSV"
Application.Dialogs(xlDialogSaveAs).Show ("Mine")

The "Mine" is a default name to place in the Save as name box.
 
Upvote 0

Forum statistics

Threads
1,223,374
Messages
6,171,727
Members
452,419
Latest member
mapa

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