Evening guys,
Wondering if you can help please, I am creating a Macro where a user can input file paths and file names and then press a button to create a back up of these files in a specified location.
This is my code when I use a fixed location (this works perfectly):
Now I try and be clever so several different teams can use it without any intervention from me, at the moment it is hard coded to the 'Validations' team as you can see by the file path.
I change it to this, using the same method that I use to specify the file path to open the file but I get a "400" error.
I have tried removing the "\backup ", this has no affect, I have tried removing the space after backup above but no luck.
Please help
Wondering if you can help please, I am creating a Macro where a user can input file paths and file names and then press a button to create a back up of these files in a specified location.
This is my code when I use a fixed location (this works perfectly):
Code:
Sub Create_Backup()
If Range("B8") = "" Then
MsgBox "Please enter at least one file location and file name"
Exit Sub
Else
Application.Workbooks.Open ("X:\" & Sheets(1).Range("B8").Text & "\" & Sheets(1).Range("C8").Text)
ActiveWorkbook.SaveCopyAs "X:\Validations backup - DO NOT DELETE\backup " & _
Format(Date, "yyyy-mm-dd") & " - " & ActiveWorkbook.Name
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
End Sub
I change it to this, using the same method that I use to specify the file path to open the file but I get a "400" error.
Code:
Sub Create_Backup()
If Range("B2") = "" Then
MsgBox "Please enter backup to location (Cell B2)"
Exit Sub
Else
If Range("B8") = "" Then
MsgBox "Please enter at least one file location and file name"
Exit Sub
Else
Application.Workbooks.Open ("X:\" & Sheets(1).Range("B8").Text & "\" & Sheets(1).Range("C8").Text)
ActiveWorkbook.SaveCopyAs "X:\" & Sheets(1).Range("B2").Text & "\backup " & _
Format(Date, "yyyy-mm-dd") & " - " & ActiveWorkbook.Name
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
End If
End Sub
Please help