How to Password protect a zip? (1 Viewer)

deletedT

Guest
Local time
Today, 02:03
Joined
Feb 2, 2019
Messages
1,218
A function in my project, opens a report, exports it to pdf, zip and password protect the pdf and sends the protected zip file as an attachment to a client.
No problem here.

This is the code that I use to zip and add a password to the pdf file:
Code:
Shell WinRarPath & " a -afzip -p123456789 -ep " & ZipName & " " & FilenameToBeZipped

-p parameter is used for adding a password and 123456789 is the password.

Up to here Everything is working perfect.

My problem:
I'm trying to find a way to use a different password each time I run the code. so I changed the code :

Code:
Dim Pass as string
Pass=CreatePassword()
Shell WinRarPath & " a -afzip -ppass -ep " & ZipName & " " & FilenameToBeZipped

The zip password is the word password not the value of it. For example if
Pass=Ab36cp1
the zip password is pass not Ab36cp1


Can anyone enlighten me how to do it?

Many thanks.
 
Last edited:

deletedT

Guest
Local time
Today, 02:03
Joined
Feb 2, 2019
Messages
1,218
I solved the problem. I had to use another string:

Code:
    Dim str As String
    Pass=CreatePassword()
    str = WinRarPath & " a -afzip -p" & Pass & " -ep " & ZipName & " " & FilenameToBeZipped
    Shell str
 

Users who are viewing this thread

Top Bottom