Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

743 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

11 Experts available now in Live!

Get 1:1 Help Now