Hi All,
I found this code online and tried to adapt it to suit my needs but i'm not having much luck. I would like to copy my test file to my weekly backup folder and include today's date in the name of the backup file when it has been copied over. Any help would be appreciated, Thanks in advance.
Sub sbCopyingAFile()
Dim FSO
Dim sFile As String
Dim sSFolder As String
Dim sDFolder As String
Dim dFile As String
dFile = sFile & Format(Date, "dd-mm-yyyy")
sFile = "test"
sSFolder = "E:"
sDFolder = "E:\weekly backup"
Set FSO = CreateObject("Scripting.FileSystemObject")
If Not FSO.FileExists(sSFolder & sFile) Then
MsgBox "Specified File Not Found", vbInformation, "Not Found"
ElseIf Not FSO.FileExists(sDFolder & sFile) Then
FSO.CopyFile (sSFolder & dFile), sDFolder, True
MsgBox "Specified File Copied Successfully", vbInformation, "Done!"
Else
MsgBox "Specified File Already Exists In The Destination Folder", vbExclamation, "File Already Exists"
End If
End Sub
I found this code online and tried to adapt it to suit my needs but i'm not having much luck. I would like to copy my test file to my weekly backup folder and include today's date in the name of the backup file when it has been copied over. Any help would be appreciated, Thanks in advance.
Sub sbCopyingAFile()
Dim FSO
Dim sFile As String
Dim sSFolder As String
Dim sDFolder As String
Dim dFile As String
dFile = sFile & Format(Date, "dd-mm-yyyy")
sFile = "test"
sSFolder = "E:"
sDFolder = "E:\weekly backup"
Set FSO = CreateObject("Scripting.FileSystemObject")
If Not FSO.FileExists(sSFolder & sFile) Then
MsgBox "Specified File Not Found", vbInformation, "Not Found"
ElseIf Not FSO.FileExists(sDFolder & sFile) Then
FSO.CopyFile (sSFolder & dFile), sDFolder, True
MsgBox "Specified File Copied Successfully", vbInformation, "Done!"
Else
MsgBox "Specified File Already Exists In The Destination Folder", vbExclamation, "File Already Exists"
End If
End Sub