Hi,
I am using this code to copy all files from 3 folders located at From Path to 3 folders located at To Path but only those files which are new or have a modification date other than the files which already exists in To Path.
Sub Copy_Files_From_To()
Dim FSO As Object
Dim FromPath(1 To 3) As String, ToPath(1 To 3) As String
Dim i As Integer
Dim Fdate As Date
Dim FileInFromFolder As Object
FromPath(1) = "\\192.168.0.100\itex share\OneDrive\Documents\DESIGNS"
FromPath(2) = "\\192.168.0.100\itex share\OneDrive\Documents\PO"
FromPath(3) = "\\192.168.0.100\itex share\OneDrive\Documents\INTERNAL SHEET"
ToPath(1) = "C:\ITEX DATA\DESIGNS"
ToPath(2) = "C:\ITEX DATA\PO"
ToPath(3) = "C:\ITEX DATA\INTERNAL SHEET"
Set FSO = CreateObject("scripting.filesystemobject")
For i = 1 To 3
If Right(FromPath(i), 1) <> "\" Then FromPath(i) = FromPath(i) & "\"
If Right(ToPath(i), 1) <> "\" Then ToPath(i) = ToPath(i) & "\"
If FSO.FolderExists(FromPath(i)) = False Then MsgBox FromPath(i) & " doesn't exist": Exit Sub
If FSO.FolderExists(ToPath(i)) = False Then MsgBox ToPath(i) & " doesn't exist": Exit Sub
For Each FileInFromFolder In FSO.getfolder(FromPath(i)).Files
Fdate = Int(FileInFromFolder.DateLastModified)
If Fdate >= DateSerial(Range("L44").Value, Range("L45").Value, Range("L46").Value) And Fdate <= DateSerial(Range("N44").Value, Range("N45").Value, Range("N46").Value) Then
FileInFromFolder.Copy ToPath(i)
End If
Next FileInFromFolder
Next i
With Sheets("INDEX")
.Unprotect Password:="merchant"
.Range("L41").Value = Now
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="merchant"
End With
End Sub
Now the change I require is that the 3 From Path Folders are on one drive. So I want the code to look at the folder available on one drive
How to tell the code to look at a URL for From Path instead of the above From Path location present in the code
Any help would be appreciated
Regards,
Humayun
Bookmarks