![]() Call CreateZipFile("C:\Users\marks\Documents\ZipThisFolder\", "C:\Users\marks\Documents\NameOFZip.zip") Change the paths to be the folder you wish to zip and the name you want the zip folder to be called. To call the procedure above the following code can be used within another procedure. On Error Resume Next Do Until ShellApp.Namespace(zippedFileFullName).items.Count = ShellApp.Namespace(folderToZipPath).items.CountĪpplication.Wait (Now + TimeValue("0:00:01")) 'Zipping the files may take a while, create loop to pause the macro until zipping has finished. ShellApp.Namespace(zippedFileFullName).CopyHere ShellApp.Namespace(folderToZipPath).items 'Copy the files & folders into the zip file Set ShellApp = CreateObject("Shell.Application") Sub CreateZipFile(folderToZipPath As Variant, zippedFileFullName As Variant)ĭim ShellApp As Object 'Create an empty zip file Open zippedFileFullName For Output As #1 Wait for all the zip files to stop compressing.Copy the files from the folder into the zip file. ![]() Declare a Variant variable to hold the file paths, this will ensure the code runs smoothly. Do not declare a String variable to hold the file paths, this will not work with the Shell.Application. UPDATE: As discussed in the comments section below.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |