C
CAM
Hello,
I desperately need help on this one. Below I have a command button coded in
Excel to copy files from the source folder to the destination folder, which
works fine. This coding is from Ron de Bruin website, which is an excellent
resource. My problem is I want to copy the files from the source folder
into the destination folder, but put a date stamp at the end of the file
name. For example "claim.xls" from the source folder and I want it to
change it to "claim01032007.xls. I want the date stamp done in every file
copied to the destination folder. Is this possible? I have many files from
the source folder. Any tips or website to visit will be appreciated. Thank
you in advance.
Private Sub cmdMoveFiles_Click()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim FileExt As String
FromPath = "D:\Test" 'From Path Folder
ToPath = "D:\Audits\" 'To Path - Destination Folder
FileExt = "*.xls"
If Right(FromPath, 1) <> "\" Then
FromPath = FromPath & "\"
End If
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & " doesn't exist"
Exit Sub
End If
If FSO.FolderExists(ToPath) = False Then
MsgBox ToPath & " doesn't exist"
Exit Sub
End If
FSO.CopyFile Source:=FromPath & FileExt, Destination:=ToPath
MsgBox "Files moved from " & FromPath & " to " & ToPath
End Sub
I desperately need help on this one. Below I have a command button coded in
Excel to copy files from the source folder to the destination folder, which
works fine. This coding is from Ron de Bruin website, which is an excellent
resource. My problem is I want to copy the files from the source folder
into the destination folder, but put a date stamp at the end of the file
name. For example "claim.xls" from the source folder and I want it to
change it to "claim01032007.xls. I want the date stamp done in every file
copied to the destination folder. Is this possible? I have many files from
the source folder. Any tips or website to visit will be appreciated. Thank
you in advance.
Private Sub cmdMoveFiles_Click()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim FileExt As String
FromPath = "D:\Test" 'From Path Folder
ToPath = "D:\Audits\" 'To Path - Destination Folder
FileExt = "*.xls"
If Right(FromPath, 1) <> "\" Then
FromPath = FromPath & "\"
End If
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & " doesn't exist"
Exit Sub
End If
If FSO.FolderExists(ToPath) = False Then
MsgBox ToPath & " doesn't exist"
Exit Sub
End If
FSO.CopyFile Source:=FromPath & FileExt, Destination:=ToPath
MsgBox "Files moved from " & FromPath & " to " & ToPath
End Sub