INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Encrypting Zip Files with separate Passwords using VBA

Encrypting Zip Files with separate Passwords using VBA

(OP)
Hello

I have used the code at this link http://www.tek-tips.com/viewthread.cfm?qid=580108 by PSUIVERSON posted below:

CODE -->

Dim source As String
Dim target As String
Dim password As String
    
source = Chr$(34) & "C:\DEPTS\050\" & Chr$(34)
target = Chr$(34) & "C:\DEPTS\050\050" & Chr$(34)

password = Chr$(34) & "JORDAN" & Chr$(34)
Shell ("C:\Program Files\WinZip\WINZIP32.EXE -min -a -sPASSWORD " & target & " " & source)

End Function 

I was able to password protect the files within the zip, but when trying to unlock those files in the zip, I found that it has applied password instead of JORDAN as the password to lock down the files.

In my project, this piece of script was added to the VBA to encrypt different zip files each with its own password, but even if I change JORDAN to a different variable String (input password from a column in a worksheet) like scripted below, the code does not take the password I provide instead the default word password.

CODE -->

Dim source As String
Dim target As String
Dim password As String
Dim pwd As String

'within loop x is the row number
pwd = Trim(Records.Cells(x, 6).Text)
source = Chr$(34) & "C:\DEPTS\050\" & Chr$(34)
target = Chr$(34) & "C:\DEPTS\050\050" & Chr$(34)

password = Chr$(34) & pwd & Chr$(34)
Shell ("C:\Program Files\WinZip\WINZIP32.EXE -min -a -spassword " & target & " " & source) 

Am I missing something? Anyone please help. Thanks.

RE: Encrypting Zip Files with separate Passwords using VBA

I would try something like:

Shell ("C:\Program Files\WinZip\WINZIP32.EXE -min -a -s & password & " " & target & " " & source)


Just a guess...

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: Encrypting Zip Files with separate Passwords using VBA

(OP)
Changed

CODE -->

Shell ("C:\Program Files\WinZip\WINZIP32.EXE -min -a -spassword " & target & " " & source) 

to

CODE -->

Shell ("C:\Program Files\WinZip\WINZIP32.EXE -min -a -s" & password & " " & target & " " & source) 

Posting in case someone else needs this, since I had been hunting for such a code for a long time and was finally able to put it together for my VBA project.

CODE -->

Dim source As String
Dim target As String
Dim password As String
Dim pwd As String

'within loop x is the row number
pwd = Trim(Records.Cells(x, 6).Text)
source = Chr$(34) & "C:\DEPTS\050\" & Chr$(34)
target = Chr$(34) & "C:\DEPTS\050\050" & Chr$(34)

password = Chr$(34) & pwd & Chr$(34)
Shell ("C:\Program Files\WinZip\WINZIP32.EXE -min -a -s" & password & " " & target & " " & source) 

That worked!! THANK YOU Andrzejek!

RE: Encrypting Zip Files with separate Passwords using VBA

You are welcome! wiggle
WOW, a stab in the dark and BINGO!
I should do the same in Powerball...

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close