DaysoutDigital
New Member
- Joined
- Sep 7, 2014
- Messages
- 5
Hi,
I am trying to make a Save As button to go into my workbook. I want the user to be able to click the button and then the Save As window pop up so they can enter the name and save the file. The location needs to be in the current folder, which I don't have a specific path to.
Also I need the same button for following sheets to just save (ie update) the file.
All the code I have found so far needs a specific path to work ie C:\data\new\new_file.xlsm
The code I'm using (which no longer works!!) is below. I'm using Excel 2010 and need it to be Macro enabled.
Sub SaveAs()
Dim save_as As Variant
Dim file_name As String
file_name = Sheets("Page 1").Range("E2")
save_as = Application.GetSaveAsFilename(file_name, _
FileFilter:="Excel Files,*.xls,All Files,*.*")
' See if the user canceled.
If save_as = False Then Exit Sub
If LCase$(Right$(save_as, 4)) <> ".xls" Then
file_name = save_as & ".xls"
End If
ActiveWorkbook.SaveAs fileName:=save_as
End Sub
Thank you for any help.
I am trying to make a Save As button to go into my workbook. I want the user to be able to click the button and then the Save As window pop up so they can enter the name and save the file. The location needs to be in the current folder, which I don't have a specific path to.
Also I need the same button for following sheets to just save (ie update) the file.
All the code I have found so far needs a specific path to work ie C:\data\new\new_file.xlsm
The code I'm using (which no longer works!!) is below. I'm using Excel 2010 and need it to be Macro enabled.
Sub SaveAs()
Dim save_as As Variant
Dim file_name As String
file_name = Sheets("Page 1").Range("E2")
save_as = Application.GetSaveAsFilename(file_name, _
FileFilter:="Excel Files,*.xls,All Files,*.*")
' See if the user canceled.
If save_as = False Then Exit Sub
If LCase$(Right$(save_as, 4)) <> ".xls" Then
file_name = save_as & ".xls"
End If
ActiveWorkbook.SaveAs fileName:=save_as
End Sub
Thank you for any help.
Last edited: