Vba - zip files & password protect zip

moni_tm

New Member
Joined
Nov 4, 2015
Messages
29
Good Afternoon,

I am trying to find some code that will help me ZIP each file individually in a specific / predetermined location using WINZIP64.exe adding the same password to each zip file.

I have kind of gone through circle a bit on the internet. As a bit of background; I have a macro which organises some a set of data and then creates a pdf from a workbook. We then want to zip each of these pdf's into a password protected zip file which would then be e-mailed out.

I believe the below code will cycle or loop through the files in the folder, I now need help in creating the code to create the individually password protected zip file.

Code:
Sub ZIP()


    Dim directory As String
    directory = Sheets("MASTER").Range("I11").Value & "\"
  
    Dim fso, newFile, folder, files
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    Set folder = fso.GetFolder(directory)
    Set files = folder.files
    
    For Each file In files


'INSERT ZIP CODE HERE








'END ZIP CODE HERE
    Next


End Sub

As always, all help is greatly appreciated.

Tom
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi Tom,

I have done this type of thing LONG time ago. But I found many nice code snippets when I used “vba code to compress excel file” as a search term. Look around and pick the one you like most. After you are done please post the code so others may benefit from it.
 
Upvote 0

Forum statistics

Threads
1,215,639
Messages
6,125,967
Members
449,276
Latest member
surendra75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top