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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| '==============================================
'Fonction récursive de parcours d'un répertoire
'==============================================
Sub ParcoursRepT()
Call stRecInit
Call ParcoursRepB(stRepIA, stRepIB)
End Sub
Sub stRecInit()
Set oFSO = CreateObject("Scripting.FileSystemObject")
stRepIA = "C:\Users\XXX\Documents\pdf\"
stRepIB = "C:\Users\XXX\Documents\test\"
End Sub
Sub ParcoursRepB(ByVal stRepB As String, ByVal stRepA As String)
If oFSO.FolderExists(stRepB) And oFSO.FolderExists(stRepA) Then
Set oFldB = oFSO.GetFolder(stRepB)
For Each oSubFolderB In oFldB.SubFolders
If oSubFolderB = "" Then
MsgBox "coucou"
End If
B = Dir(oSubFolderB & "\")
cpt = 0
Set oFldA = oFSO.GetFolder(stRepA)
For Each oSubFolderA In oFldA.SubFolders
For Each oFileA In oSubFolderA.Files
NomA = Left(oFileA.Name, Len(oFileA.Name) - 4)
NomB = Left(B, Len(B) - 3)
cpt = cpt + 1
If NomA <> NomB Then
Else
dtA = FileDateTime(oFileA)
dtA = Format(dtA, "DD-MM-YYYY HH")
'MsgBox ("" & dtA)
dtB = FileDateTime(oSubFolderB & "\" & B)
chemin_C = oSubFolderB & "\" & B
dtB = Format(dtB, "DD-MM-YYYY HH")
'MsgBox ("" & dtB)
If dtA <= dtB Then
'MsgBox "RAF"
B = Dir(oSubFolderB & "\")
For i = 1 To cpt
If B = "" Then
Else
B = Dir()
End If
Next
Else
Set doc = Documents.Open(oFileA)
'NomA = Left(oFileA, Len(oFileA) - 4) & "pdf"
doc.ExportAsFixedFormat visFixedFormatPDF, chemin_C, visDocExIntentPrint, visPrintAll
doc.Close
B = Dir(oSubFolderB & "\")
For i = 1 To cpt
B = Dir()
Next
End If
End If
Next oFileA
If (oFileA Is Nothing) And (B <> "") Then
MsgBox ("Fichier PDF unique, suppression en cours ! ")
Kill (oFileB)
Else
End If
ParcoursRepB oSubFolderB.Path, oSubFolderA.Path
Next // LE BUG CE SITUE ICI, IL NE SAUTE PAS CETTE ETAPE LORSQU IL DOIT CHOISIR UN AUTRE DOSSIER
Next
End If
End Sub |
Partager