1 Replies - 3133 Views - Last Post: 29 June 2010 - 12:20 AM

#1 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Zip files with WinZip in VB6

Posted 10 February 2009 - 11:11 PM

Description: Provide an array of file names, their directories and the name you want the zip file namedThis is a snippet for zipping files with the WinZip executable. It expects an array of file names, their directory and the name you want the zip file named as parameters. It then loops through each file adding them to your zip file
Private Sub ZipFileWithWinZip(ByRef files() As String, ByRef dir As String, ByRef zipFileName As String)
    'Change this to your path for Winzip
    Const EXE_LOCATION As String = """" & "C:Program FilesWinZipwzzip" & """"
    Dim cmd As String
    Dim i As Integer
    
    If Right$(dir, 1) <> "" Then dir = dir & ""

    'Now we need to work through the array of files
    For i = 1 To UBound(info)
        'Zip the current file
        cmd = EXE_LOCATION & " " & zipFileName & " " & files(i)
        Debug.Print cmd
        
        'Check the status of the zip process
        If Shell(cmd, vbHide) = 0 Then
        'See if they want to continue
            If MsgBox("Zip Failed for " & files(i) & vbCrLf & "Continue?", vbExclamation Or vbYesNo, "Zip Error") = vbNo Then
                Exit For
            End If
        End If
        
        'Move to the next file
    Next i

    MsgBox "All files zipped", vbInformation, "Zip Process Complete", vbOK
End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: Zip files with WinZip in VB6

#2 kanchanad   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 28-June 10

Re: Zip files with WinZip in VB6

Posted 29 June 2010 - 12:20 AM

While trying to execute the snippet i got the following doubts.. Could you Explain the lines 1."cmd = EXE_Location & " " & zipFileName & " " & files(i)" - what for this cmd variable?is it for taking source to zip or destination place to put zipped files? 2.is this variable"EXE_LOCATION" refers to the winzip.exe file in my pc.If it so there are 3 exe's in C:\program files\winzip\ path 3. variable 'info' in the line "For i = 1 To UBound(info)" should be replaced with 'files'
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1