TaskMaster
Board Regular
- Joined
- Oct 15, 2020
- Messages
- 75
- Office Version
- 365
- 2016
- Platform
- Windows
Hi All,
I have the following which will copy a list of files and paste them into my monthly folder as needed. Is there a way to notify me if any of these files aren't in the Folder location and can't be copied. Also is it possible to add if this file already exists in the new location do not copy?
I have the following which will copy a list of files and paste them into my monthly folder as needed. Is there a way to notify me if any of these files aren't in the Folder location and can't be copied. Also is it possible to add if this file already exists in the new location do not copy?
VBA Code:
Sub Copy_Files()
Dim Folder As String
Dim Dest As String
Dim fso As Object
Dim LastMonth As Date
Set fso = VBA.CreateObject("Scripting.FileSystemObject")
LastMonth = DateSerial(Year(Date), (Month(Date) - 1), Day(Date))
Folder = "\\users\TM\Desktop\Test\"
Dest = "\\users\TM\Desktop\Test\" & Format(LastMonth, "mm. ") & Format(LastMonth, "mmmm") & "\Data\Reports"
Call fso.CopyFile(Folder & "330016*", Dest)
Call fso.CopyFile(Folder & "330008*", Dest)
Call fso.CopyFile(Folder & "330009*", Dest)
Call fso.CopyFile(Folder & "330010*", Dest)
Call fso.CopyFile(Folder & "330011*", Dest)
Call fso.CopyFile(Folder & "330013*", Dest)
Call fso.CopyFile(Folder & "330014*", Dest)
Call fso.CopyFile(Folder & "334008*", Dest)
Call fso.CopyFile(Folder & "334009*", Dest)
Call fso.CopyFile(Folder & "334010*", Dest)
Call fso.CopyFile(Folder & "334011*", Dest)
Call fso.CopyFile(Folder & "358026*", Dest)
Call fso.CopyFile(Folder & "358027*", Dest)
End Sub