1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
Option Explicit
Public timR As Variant
Public Const proC = "TransferFiles"
Sub timer()
timR = TimeValue(Now + TimeValue("00:00:10"))
Application.OnTime timR, proC
End Sub
Function GetMissingFiles(Source As Range, Target As Range)
Const GenericFormula As String = "match(""{file}"",t_Cible[Name],0)"
Dim Formula As String
Dim f, Pos
Dim s As Range, t As Range
ReDim f(0)
For Each s In Source
Formula = Replace(GenericFormula, "{file}", s.Value, , , vbTextCompare)
Pos = Evaluate(Formula)
If IsError(Pos) Then
If Not IsEmpty(f(0)) Then ReDim Preserve f(UBound(f) + 1)
f(UBound(f)) = s.Value
End If
Next
GetMissingFiles = f
End Function
Sub TranferFiles()
Dim MissingFiles
Dim SourcePath As String, TargetPath As String
Dim SourceName As String, TargetName As String
Dim i As Long
SourcePath = "\\hbe-lc2is-portal.hrfd.ms.fr\DavWWWRoot\VJTF(BFA)\Documents\RECEIVED\01 Situational Awareness\01 Reports\OVERLAYS\"
TargetPath = "\\hbe-lc2is-portal.hrfd.ms.fr\DavWWWRoot\OfficialHQ\Documents\OVERLAYS\"
MissingFiles = GetMissingFiles(Range("t_Source"), Range("t_Cible"))
For i = LBound(MissingFiles) To UBound(MissingFiles)
SourceName = SourcePath & MissingFiles(i)
TargetName = TargetPath & MissingFiles(i)
FileCopy SourceName, TargetName
Next i
End Sub |
Partager