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
|
Sub Tst2()
Dim iRow As Long, LastRow As Long, sChemin As String
Dim FSO As Scripting.FileSystemObject
Dim Dossier As Scripting.Folder
LastRow = ShDatas.Range("A" & Rows.Count).End(xlUp).Row
ShDatas.Columns("B:B").Clear
Application.ScreenUpdating = False
Set FSO = New Scripting.FileSystemObject
For iRow = 1 To LastRow
sChemin = ShDatas.Cells(iRow, 1)
If ExistenceDossier(sChemin) = True Then
Set Dossier = FSO.GetFolder(sChemin)
ShDatas.Cells(iRow, 2) = Dossier.Size
End If
Next iRow
Application.ScreenUpdating = True
Set Dossier = Nothing
Set FSO = Nothing
End Sub
Private Function ExistenceDossier(NomDossier As String) As Boolean
ExistenceDossier = Dir(NomDossier, vbDirectory) <> "" And Len(NomDossier) > 0
End Function |
Partager