Bonjour à tous,
une proposition à tester, à adapter le nom du répertoire dans la macro LoopDossiers :
Sub NewZip(sPath)
If Len(Dir(sPath)) > 0 Then Kill sPath
Open sPath For Output As #1
Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
Close #1
End Sub
Sub LoopDossiers()
Dim FileSystem As Object
Dim HostFolder As String
HostFolder = "C:\Users\Sequoyah\Desktop\Forum\" '=====>> A adapter
Set FileSystem = CreateObject("Scripting.FileSystemObject")
DoFolder FileSystem.GetFolder(HostFolder)
End Sub
Sub DoFolder(Folder)
Dim SubFolder
Dim File
Dim FileNameZip, FolderName
Dim strDate As String, DefPath As String
Dim oApp As Object
For Each SubFolder In Folder.subfolders
DoFolder SubFolder
DefPath = Folder
If Right(DefPath, 1) <> "\" Then
DefPath = DefPath & "\"
End If
FolderName = SubFolder
FileNameZip = DefPath & SubFolder.Name & ".zip"
NewZip (FileNameZip)
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameZip).CopyHere oApp.Namespace(FolderName).items
On Error Resume Next
Do Until oApp.Namespace(FileNameZip).items.Count = _
oApp.Namespace(FolderName).items.Count
Application.Wait (Now + TimeValue("0:00:01"))
Loop
On Error GoTo 0
Next
End Sub