CreateZipFile_7Zip

Compress a single file into zip archive using 7Za.exe
7za,exe (found in attached zip) file expected to be in a folder called "Resources" next to that workbook.
Function waits for the archive to complete

Sub CreateZipFile_7Zip(Filepath, ZipFile)
 ' Creates a Zip file from a single file
 Cmd1 = Chr(34) & FixPath(FixPath() & "Resources") & "7za.exe" & Chr(34)
 Cmd2 = " a -tzip "
 Cmd3 = Chr(34) & ZipFile & Chr(34)
 Cmd4 = " " & Chr(34) & Filepath & "" & Chr(34)
 Set oShell = CreateObject("WSCript.shell")
 oShell.Run Cmd1 & Cmd2 & Cmd3 & Cmd4, 1, True
 DoEvents
End Sub

Parameters

Filepath, ZipFile

Views 156 Downloads 67

Perm link