Solved

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

Posted on 2004-04-29
5
1,069 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 70

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

808 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