Unzip file without any tupe of library

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Unzip file without any tupe of library

Post by sal21 »

From c:\mydir\miofile.zip to c:\mydir\unzipped\
Possible withouth any 3d part and exetrnal library?
Tks

User avatar
SpeakEasy
4StarLounger
Posts: 562
Joined: 27 Jun 2021, 10:46

Re: Unzip file without any tupe of library

Post by SpeakEasy »

Depends very much by how you are defining 3rd party or external library. The Window Shell can do it ... But that's external . But if that's OK, then:

Code: Select all

Public Sub Example()
    Dim strSourceZip As Variant ' do not make this a String
    Dim strTargetFolder As Variant ' do not make this a String
    
    strSourceZip = "D:\Downloads\1848_lvheader.zip"
    strTargetFolder = "D:\Downloads\DeleteMe\unzips"
    
    With CreateObject("Shell.Application")
        .Namespace(strTargetFolder).CopyHere .Namespace(strSourceZip).Items ' all contents of zip folder
        '.Namespace(strTargetFolder).CopyHere .Namespace(strSourceZip).Items.Item("frmLVClrHdr.frm") ' single file from zip
    End With
End Sub

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Re: Unzip file without any tupe of library

Post by sal21 »

SpeakEasy wrote:
27 Jul 2023, 13:13
Depends very much by how you are defining 3rd party or external library. The Window Shell can do it ... But that's external . But if that's OK, then:

Code: Select all

Public Sub Example()
    Dim strSourceZip As Variant ' do not make this a String
    Dim strTargetFolder As Variant ' do not make this a String
    
    strSourceZip = "D:\Downloads\1848_lvheader.zip"
    strTargetFolder = "D:\Downloads\DeleteMe\unzips"
    
    With CreateObject("Shell.Application")
        .Namespace(strTargetFolder).CopyHere .Namespace(strSourceZip).Items ' all contents of zip folder
        '.Namespace(strTargetFolder).CopyHere .Namespace(strSourceZip).Items.Item("frmLVClrHdr.frm") ' single file from zip
    End With
End Sub
TKS.
WORK PERFECT!