Solved

How do I zip a whole FOLDER using Winzip command line code (Microsoft Access VBA module)

Posted on 2004-04-29
5
1,067 Views
Last Modified: 2007-12-19
I use the following sub/function to zip individual FILES, and it works great:

Public Sub WinZipFile(strFileName As String, strDest As String, Optional strPassword As Variant)
    Dim strShell As String
    If IsMissing(strPassword) Then
        strShell = "c:\progra~1\winzip\wzzip.exe " & strDest & " " & strFileName    'WINZIP32.EXE
    Else
        strShell = "c:\progra~1\winzip\wzzip.exe -s" & strPassword & " " & strDest & " " & strFileName
    End If    
    Shell (strShell)
End Sub

But I cannot figure out how to zip a whole FOLDER. HELP! How do I need to modify the code to zip a folder or does somebody have code that does work?

Thanks

Susanne
0
Comment
Question by:ss250375
5 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 10954824
0
 
LVL 76

Accepted Solution

by:
David Lee earned 125 total points
ID: 10955135
According to the WinZip Command Line Support Add-On the correct syntax for that is:

Wzzip Zipfile Files

So

Wzzip MyZipFile.Zip C:\*.*

would get all the files in the root of C:.  

In your code example you just need to pass a full path, to include *.*, in strFileName instead of the name of a single file.
0
 
LVL 1

Expert Comment

by:Shaztronics
ID: 10955718
'example use: WinZipit "D:\pscDownload\achoopump vs "ladybug 2playergame.zip","C:\unziphippie1",Zip

Public Sub WinZipit(ByVal strSource As String, _
                    ByVal strTarget As String, _
                    Mode As Winzip)
 
  Dim strWinZip         As String 'string for winzip
  Dim strWinZiplocation As String 'location of Winzip
  Dim RetVal
    strWinZiplocation = "C:\Program Files\WinZip\WINZIP32.EXE"
   
    Select Case Mode
     Case Winzip.ZIP
        strWinZip = strWinZiplocation & " -a " & Chr$(34) & strTarget & Chr$(34) & "; " & Chr$(34) & strSource & Chr$(34)
     Case Winzip.UNZIP
        strWinZip = strWinZiplocation & " -e " & Chr$(34) & strSource & Chr$(34) & "; " & Chr$(34) & strTarget & Chr$(34)
     Case Else
    End Select
   
    RetVal = Shell(strWinZip, vbHide)
End Sub
0
 

Expert Comment

by:vbharikrishna
ID: 10957951
Simple code for zipping whole directoty

Dim retval As Double
retval = Shell("C:\program files\winzip\WINzip32 -a -r -p F:\HariBackup\HRMSoftwareBackup\Exports" & Format(Now, "DDMMMYYYY") & ".zip " & App.Path & "\*.*", vbMinimizedNoFocus)

Note:- instead of  "F:\HariBackup\HRMSoftwareBackup\Exports" & Format(Now, "DDMMMYYYY") & ".zip "  give u r target file location
0
 

Author Comment

by:ss250375
ID: 10964280
Thanks to everybody for your assistance and great tips. Too bad the points cannot be distributed between everybody. Susanne.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel Spreadsheet - Send email if certain value is selected. 14 86
Use closed file on desktop in vba 6 65
Passing a Text Box name to a Sub 6 74
VB6 ListBox Question 4 32
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now