PDA

View Full Version : Unzip FilesBy VBA



Rajan_Verma
10-20-2011, 09:16 PM
If you need to Unzip files From a Zip Folder you can use this Codes :





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/2011/07/unzip-filesby-vba.html

Junoon
05-14-2012, 12:11 AM
can you post a function or procedure example to zip a file/files?