Home Copying Specific File from Zip Files VBA
Reply: 0

Copying Specific File from Zip Files VBA

user1780 Published in July 21, 2018, 1:47 pm

I am trying to copy specific file from zip files. The following code running succesfully but it not copy the file from zip to Folder.

Any suggestion would be appreciated..

 Sub Unzip5()
        Dim FSO As Object
        Dim oApp As Object
        Dim Fname As Variant
        Dim FileNameFolder As Variant
        Dim DefPath As String
        Dim strDate As String
        Dim I As Long
        Dim num As Long

        Fname = Application.GetOpenFilename(filefilter:="Zip Files (*.zip), *.zip", _
        If IsArray(Fname) = False Then
            'Do nothing

            FileNameFolder = "D:\Template\test\"

            Set oApp = CreateObject("Shell.Application")

          For I = LBound(Fname) To UBound(Fname)
                num = oApp.Namespace(FileNameFolder).Items.Count
                        For Each fileNameInZip In oApp.Namespace(Fname(I)).Items
                                    If fileNameInZip Like "repo*" Then
                                        oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(Fname(I)).Items.Item(CStr(fileNameInZip)) 
'this above line working fine but not copying file from zip
                                        Exit For
                                    End If
                'oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(Fname(I)).Items

            Next I

            MsgBox "You find the files here: " & FileNameFolder

            On Error Resume Next
            Set FSO = CreateObject("scripting.filesystemobject")
            FSO.deletefolder Environ("Temp") & "\Temporary Directory*", True
        End If
    End Sub
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299247 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO