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

Filepath, ZipFile

Views 418 Downloads 159

'FixPath', '7za', 'Zip', '7zip', '7za.exe', 'archive', 'compress', 'file', 'shell', 'wait'

ANmarAmdeen
324
Attachments
File System VBA-Excel
Revisions

v1.0