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
| Option Explicit
Sub test()
Dim ws1 As Worksheet
Dim PL As Long, DL As Long, i As Long
Dim Fso As Object
Dim msg As String
Dim cheminSource As String
Dim cheminCible As String
Dim nomFichier As String
'....
'
Set Fso = CreateObject("scripting.filesystemobject")
cheminCible = "\\Station-serveur\MAISON DELAHAYE\PHOTOS & FT FOURNISSEURS\..PHOTOS DU SITE\PHOTOS PRIMAIRES\DN CENTRALISEES\"
For i = PL To DL
If ws1.Cells(i, 122) > 0 Then 'condition de base)
'Chemin de stockage de la photo DN, détourée, recadrée,
cheminSource = Cells(i, 63).Value
nomFichier = Cells(i, 59).Value
'Test présence photo: En cellule59, le nom du fichier photo, xxx.jpg
If Dir(cheminSource & nom) = "" Then
msg = msg & vbCrLf & "- " & nomFichier
Else
Fso.Copyfile cheminSource & nomFichier, cheminCible & nomFichier, True
End If
End If
Next i
If msg > "" Then MsgBox "Photo(s) absente(s) :" & msg, vbCritical
End Sub |
Partager