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
| '-----------------Pièces jointes------------------------------------------------------------------------------------------------------
p = UD.Cells(Rows.Count, "E").End(xlUp).Row - 2
For l = 2 To p
fichierpdf = UD.Range("e" & l).Value
Set fso = CreateObject("Scripting.FileSystemObject")
Set dossier = fso.GetFolder("S:\bbbbbbb\ACTIVITY\CLIENTS\")
z = dossier.SubFolders.Count
nomdossier = UCase(UD.Range("A2").Value)
Worksheets("Recipients CC").Range("G:K").Clear
Set dossiercompany = fso.GetFolder("S:\bbbbbbb\ACTIVITY\CLIENTS\" & nomdossier & "\" & UCase("Invoicing"))
Debug.Print dossiercompany
' MsgBox nomdossier
For Each sousdossiercompany In dossiercompany.SubFolders
m = sousdossiercompany.Name
lngrow = lngrow + 1
If IsNumeric(m) And m <> "Trams" Then
Worksheets("Recipients CC").Range("G" & lngrow).Value = CInt(m)
End If
Next sousdossiercompany
derlng = Worksheets("Recipients CC").Cells(Rows.Count, "G").End(xlUp).Row
If Worksheets("Recipients CC").Range("G" & derlng).Value > Worksheets("Recipients CC").Range("G" & derlng - 1).Value Then
ssdossier = CStr(Worksheets("Recipients CC").Range("G" & derlng).Value)
End If
Dim mesfichiers, t()
chemin = dossiercompany & "\" & ssdossier ' racine pour la recherche
Debug.Print chemin
exT = ".pdf" ' extention de fichiers recherchés
argmt1 = fichierpdf ' partie du nom de fichiers recherchés
mesfichiers = cherche(chemin, exT, argmt1) ' ||mesfichiers|| deviendra un tableau de nom de fichiers selon les condition précédemment énumérée
If UBound(mesfichiers) > 0 Then
'MsgBox Join(mesfichiers, vbCrLf)
i = i + 1
UD.Range("M" & i).Value = mesfichiers
End If
Next l
PieceJointe = PieceJointe
For u = 2 To UD.Range("M65536").End(xlUp).Row - 1
PieceJointe = PieceJointe & "; " & UD.Range("M" & u).Value
Debug.Print PieceJointe
Next |
Partager