Consulting

Results 1 to 8 of 8

Thread: Unzip Problem using Ron de Bruin's code

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    864
    Location
    This seems to work. HTH. Dave
     
    Sub FolderFiles()
        ' unzip all zipped files in folder
        Dim FolderPath As String, AllZip As String
        FolderPath = "D:\testfolder" 'folder containing zip files
        AllZip = Dir(FolderPath & "\*.zip")
        Do While AllZip <> ""
            Call Unzip(FolderPath & "\", FolderPath & "\" & AllZip)
            AllZip = Dir
        Loop
    End Sub
     
    Public Function Unzip(DefPath, Fname)
        ' Many thanks to Ron de Bruin for his great code
        ' Unzips A File
        ' Fname must be FULL Path\Filename.zip
        ' DefPath must be valid Path you want to Unzip file TO
        ' You just need to pass 2 strings.
        ' C:\FullPath\Filename.zip - the file to UNZIP
        ' C:\FullPath\ - folder to unzip to
        Dim FSO As Object
        Dim oApp As Object
        Set oApp = CreateObject("Shell.Application")
        oApp.Namespace(DefPath).CopyHere oApp.Namespace(Fname).items
        On Error Resume Next
        Set FSO = CreateObject("scripting.filesystemobject")
        FSO.deletefolder Environ("Temp") & "\Temporary Directory*", True
        Set FSO = Nothing
        Set oApp = Nothing
    End Function
    Last edited by Aussiebear; 04-15-2025 at 06:05 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •