Option Explicit
Sub ZipFichier()
Dim oShell As Object
Dim FSO As Object
Dim i As Long
Dim sFichier As String, sBin As String
Dim sZip As Variant, vHexa As Variant
sFichier = ThisWorkbook.Path & "\" & "Essai.xls"
sZip = ThisWorkbook.Path & "\" & "Essai.zip"
Set FSO = CreateObject("Scripting.FileSystemObject" )
vHexa = Array(80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
For i = 0 To UBound(vHexa)
sBin = sBin & Chr(vHexa(i))
Next i
With FSO.CreateTextFile(sZip, True)
.Write sBin
.Close
End With
Set oShell = CreateObject("Shell.Application" )
oShell.Namespace(sZip).CopyHere (sFichier)
Set oShell = Nothing
Set FSO = Nothing
End Sub |