extract a file from .ZIP using VB or VBA

Nishikawa

Registered User.
Local time
Today, 14:35
Joined
May 17, 2007
Messages
97
Hi,

If there code available to extract one single file from a zip package and transfer it to a specific folder?
 
i have this:-

Code:
'---------------------------------------------------------------------------------------
' Procedure : UnZip_ZipFile
' Author    : Darth Vodka
' Date      : 27/11/07
' Purpose   : unzips a file to a certain location
'           : if the targetfile is specified, it renames the last file it has created (so it won't rename all
'           : if there are many in the extract)
'---------------------------------------------------------------------------------------
'
Sub UnZip_ZipFile(strZippedFileName As String, strTargetFolder As String, Optional strTargetFile As String)
    Const PATHWINZIP        As String = "C:\progra~1\winzip\"
    Dim ShellStr            As String
    
    On Error GoTo ErrorHandler

    ClearDirectory strTargetFolder
    WaitFor 2

    'This will check if this is the path where WinZip is installed.
    If Dir(PATHWINZIP & "winzip32.exe") = "" Then
        MsgBox "Please find your copy of winzip32.exe and try again"
        Exit Sub
    End If
 
    'Unzip the zip file in the folder FolderName
    ShellStr = PATHWINZIP & "Winzip32 -min -e" _
             & " " & Chr(34) & strZippedFileName & Chr(34) _
             & " " & Chr(34) & strTargetFolder & Chr(34)
    Shell ShellStr, vbHide
    
    If IsMissing(strTargetFile) = False Then
        WaitFor 2
        FileCopy strTargetFolder & Dir(strTargetFolder), strTargetFolder & strTargetFile
    End If
    
    Exit Sub
    
ErrorHandler:

    With Err
        Select Case .Number
        
            Case Else
                ErrorLog .Number, .Description, "modUtilities", "DeleteImportFiles"
    
        End Select
    End With
    
End Sub
 
Hi,
How Would I do the opposite, i.e. zip a folder incuding all files within it.
Regards
D
 

Users who are viewing this thread

Back
Top Bottom