Solved

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

Posted on 2004-04-29
5
1,086 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

738 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