Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Contents of a Zip File 1

Status
Not open for further replies.

Mach01

Technical User
Oct 17, 2012
1
EU
I am trying to find the contents of a zip file. I found this code on the forum but it only finds the first layer of the structure and not the folders sub folders and their contents.

Code:
Dim shApp As Shell32.Shell
Dim shFolder As Shell32.Folder, shFolder2 As Shell32.Folder
Dim shFolderItem As Shell32.FolderItem, shFolderItem2 As Shell32.FolderItem
Set shApp = New Shell32.Shell
Set shFolder = shApp.NameSpace("FolderPath")
Set shFolderItem = shFolder.ParseName("Filename.zip")
Set shFolder2 = shFolderItem.GetFolder
For Each shFolderItem2 In shFolder2.Items
    Debug.Print shFolderItem2.Name
Next shFolderItem2

Thanks
 
This one should pull out everything:

Function TestMe()
Call ExtractAll("Z:\Software Development\Code11.zip", "Z:\Common\Zipout")
End Function

Function ExtractAll(strZipFile, strTargetFolder)

Set objShell = CreateObject("Shell.Application")

Set objFso = CreateObject("Scripting.FileSystemObject")

If Not objFso.FolderExists(strTargetFolder) Then

objFso.CreateFolder (strTargetFolder)

End If



intCount = objShell.NameSpace(strTargetFolder).Items.Count

Set colItems = objShell.NameSpace(strZipFile).Items

objShell.NameSpace(strTargetFolder).CopyHere colItems, 256

Do Until objShell.NameSpace(strTargetFolder).Items.Count = intCount + colItems.Count

WScript.Sleep 200

Loop

End Function

'this one is supposed to pop a Wizard to allow the user to select the target folder, but I've never tested it, doesn't work on Terminal Server, might work on a local install:

Function ExtractAllW(strZipFile)

Set objShell = CreateObject("Shell.Application")

Set WshShell = CreateObject("WScript.Shell")

objShell.NameSpace(strZipFile).Items.Item.InvokeVerb ("Extract &All?")

Do While WshShell.AppActivate("Extraction Wizard")

WScript.Sleep 200

Loop

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top