Excel 2010 Save button

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.
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
.
.

Code:
Private Sub CommandButton1_Click()

    Dim ffilt As String
    Dim fname As String
    
    ffilt = "Excel 97-2003 Workbook (*.xls),*.xls"
    fname = Application.GetSaveAsFilename( _
        FileFilter:=ffilt)
    
    If fname = "False" Then Exit Sub
    
    ThisWorkbook.SaveAs _
        Filename:=fname, _
        FileFormat:=xlExcel8

End Sub
 
Last edited:
Upvote 0
Well thank you gpeacock, that code didn't exactly work how I wanted but it did get me going and I have now got something working pretty well:

Sub Save_As ()

Dim ShName As String
ShName = "Page 1"
MyPath = ThisWorkbook.Path & "\"

ActiveWorkbook.SaveAs FileName:=MyPath & Worksheets(ShName).[e2] & Format(Now, "_dd_mm_yy") & ".xlsm"

End Sub

This seems to be holding out for the first page save as function I needed - and it is naming the file using a value from my worksheet and the date in the same folder as the original file.

Now that I am here is there any way I can activate my NEXT button only after the SaveAs function has ran?

Thank you for you help...
 
Upvote 0
And just to round it off this is the Save a Copy code,

Sub Save_Copy()

ActiveWorkbook.Save

ActiveSheet.Next.Select

End Sub


and it moves to the next sheet too! I'm killing it tonight - simple things I guess.
 
Upvote 0

Forum statistics

Threads
1,223,579
Messages
6,173,171
Members
452,504
Latest member
frankkeith2233

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