Code for Unzipping a Zip File

Following is a VBS function that unzips the given file into the given path :

Public Function Extract_Zip(TestZip,ExtractToTest)

'TestZip is the Zip file to be extracted and ExtractToTest is the location where it needs to be extracted
'ensuring that Testzip has .zip extension
If instr(1,TestZip,".zip",1)=0 Then
End If

'Deleting and then creating folder where zip file is extracted
Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FolderExists(ExtractToTest) Then
End If

If NOT fso.FolderExists(ExtractToTest) Then
End If

'Extract the contents of the zip file.
set objShell = CreateObject("Shell.Application")
set FilesInZip=objShell.NameSpace(TestZip).items
Set fso=nothing
Set objShell=nothing

End Function

Happy Automating !

Harshit Kohli


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s