Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-04-29
5
Medium Priority
?
1,110 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 500 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 Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

610 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