Results 1 to 2 of 2

Thread: Unzip FilesBy VBA

  1. #1
    Member Rajan_Verma's Avatar
    Join Date
    Sep 2011
    Posts
    81
    Rep Power
    13

    Lightbulb Unzip FilesBy VBA

    If you need to Unzip files From a Zip Folder you can use this Codes :



    Code:
    Option Explicit
    
    Sub UnzipAFile()
        Dim ShellApp As Object
        Dim TargetFile
        Dim ZipFolder
    
    '   Target file & temp dir
        TargetFile = Application.GetOpenFilename _
            (FileFilter:="Zip Files (*.zip), *.zip")
        If TargetFile = False Then Exit Sub
       
        ZipFolder = Application.DefaultFilePath & "\Unzipped\"
    
    '   Create a temp folder
        On Error Resume Next
        RmDir ZipFolder
        MkDir ZipFolder
        On Error GoTo 0
    
    '   Copy the zipped files to the newly created folder
        Set ShellApp = CreateObject("Shell.Application")
        ShellApp.Namespace(ZipFolder).CopyHere _
           ShellApp.Namespace(TargetFile).items
    
        If MsgBox("The files was unzipped to:" & _
           vbNewLine & ZipFolder & vbNewLine & vbNewLine & _
           "View the folder?", vbQuestion + vbYesNo) = vbYes Then _
           Shell "Explorer.exe /e," & ZipFolder, vbNormalFocus
    End Sub
    http://excelpoweruser.blogspot.com/2...lesby-vba.html

  2. #2
    Junior Member
    Join Date
    May 2012
    Posts
    25
    Rep Power
    0
    can you post a function or procedure example to zip a file/files?

Tags for this Thread

Posting Permissions

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