Create zip from list of files listed in List_of_Files separated by comma.
The list needs to have full path and file names of all files to be compressed
Code will create a temp file needed having list of files (you do not need to create that), then call 7za to compress all these files
7za,exe (found in attached zip) expected to be in a folder called "Resources" next to that workbook.
Function does not wait for archive to finish

Sub CreateZipFiles_7Zip(List_of_Files, ZipFile, Optional Sep1=",")
 ' Creates a Zip file having all files listed in List_of_Files that is separated by comma
 ' First function needs to have a txt file having list of files
 Fii = Replace(List_of_Files, Sep1, vbcrlf)
 Fi2 = FixPath(FixPath() & "Resources") & "TempFiles.txt"
 If IsThere1(Fi2, True, True) Then Kill Fi2
 Open Fi2 For Output As #1
 Print #1, Fii
 Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 1)
 ' Then we call to archive all these files
 Cmd1 = Chr(34) & FixPath(FixPath() & "Resources") & "7za.exe" & Chr(34)
 Cmd2 = " a -tzip "
 Cmd3 = Chr(34) & ZipFile & Chr(34)
 Cmd4 = " @" & Chr(34) & Fi2 & Chr(34)
 Shell Cmd1 & Cmd2 & Cmd3 & Cmd4, vbHide
 Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 1)
 Kill Fi2
End Sub

List_of_Files, ZipFile, Optional Sep1

Views 1424 Downloads 593

'FixPath', 'IsThere1', '7za', 'Zip', '7zip', '7z', '7za.exe', 'archive', 'compress', 'files', 'lit of files'

File System VBA-Excel