Can anyone help me with this Savefilebutton Code to re update it

Status
Not open for further replies.

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
2,079
Office Version
  1. 365
Platform
  1. Windows
I would like to use this code without the input require pop up. I just want to add in the code to the name of the file its saving and the folder where to say it thanks. Without using the input required pop up. Thanks


Sub SaveFileButton()
Dim SaveName As String
Const MyPath As String = "C:\Test\" 'This is the path it's using for saves before the dates
ReName:
On Error GoTo ErrorHandle


SaveName = Trim(InputBox("Enter the file name you want to save. (blank to skip)", "Input required."))
If Len(SaveName) > 0 Then
SaveName = SaveName & ".xlsx"
If Len(Dir(MyPath & Format(Now, "yy") & "-" & Format$(Now, "mmm"), vbDirectory)) = 0 Then
MkDir MyPath & Format(Now, "yy") & "-" & Format$(Now, "mmm") & "\"
End If
If Len(Dir(MyPath & Format(Now, "yy") & "-" & Format$(Now, "mmm") & "\" & Format(Now, "mm") & "-" & Format(Now, "dd") & "-" & Format(Now, "yyyy"), vbDirectory)) = 0 Then
MkDir MyPath & Format(Now, "yy") & "-" & Format$(Now, "mmm") & "\" & Format(Now, "mm") & "-" & Format(Now, "dd") & "-" & Format(Now, "yyyy") & "\"
End If
ActiveWorkbook.SaveAs Filename:=MyPath & Format(Now, "yy") & "-" & Format$(Now, "mmm") & "\" & Format(Now, "mm") & _
"-" & Format(Now, "dd") & "-" & Format(Now, "yyyy") & "\" & SaveName, FileFormat:=xlOpenXMLWorkbook
End If

Exit Sub

ErrorHandle:
If Err.Number = 75 Then
Resume Next
ElseIf Err.Number = 1004 Then
MsgBox ("That name is already used for this day. Please try again!")
GoTo ReName
Else: MsgBox ("There is an unknown error")
End If
End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Duplicate: http://www.mrexcel.com/forum/excel-...uild-folders-but-has-input-required-help.html

Please do not post the same question multiple times. All clarifications, directly-related follow-ups, and bumps should be posted back to the original thread. Per forum rules, posts of a duplicate nature will be locked or deleted (rule #12 here: Forum Rules).

If you do not receive a response to your follow-up to your previous response, you can "bump" it by replying to it again, though we advise you not to bump a thread more than once a day.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,929
Messages
6,122,314
Members
449,081
Latest member
tanurai

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