Save As Macro

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

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
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,214,400
Messages
6,119,289
Members
448,885
Latest member
LokiSonic

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