Extract all Files from a Zip but not any folders

Posted on 2014-03-05
Medium Priority
Last Modified: 2014-03-10
The code below works and will extract all files and folders from a zipped file. If possible I would like it to only extract the files.

Function unZip()
Dim unZipToLoc As Variant
Dim zipFname As Variant
     unZipToLoc = "C:\Zipped"
     zipFname = DLookup("ZippedReportsName", "tDefaults")
Set oApp = CreateObject("Shell.Application")
     oApp.Namespace(unZipToLoc).CopyHere oApp.Namespace(zipFname).Items
End Function
Question by:Hiken
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 36

Assisted Solution

Kimputer earned 2000 total points
ID: 39913830
Dim unZipToLoc As Variant
Dim zipFname As Variant
     unZipToLoc = "C:\Zipped"
     zipFname = DLookup("ZippedReportsName", "tDefaults")
	Set oApp = CreateObject("Shell.Application")
	Set FilesInZip = oApp.Namespace(zipFname).Items	
	FilesInZip.Filter 64, "*.*"
End Function

Open in new window


Author Comment

ID: 39917250
it is not erroring out but it doesn't unzip any files.  There are four folders inside the zip before the text files so it looks like this:

ZippedAll.zip\scowebreports\reports\FB6122\2014068\  then the text files.  The last folder 2014068 changes daily.
LVL 36

Accepted Solution

Kimputer earned 2000 total points
ID: 39917354
Because you said "only files", I understood is as only the files in in the root folder.
In this case, it's better to unzip as normal (use your old code), and then add code to recursively move files from the subfolders to the root folder, and delete the subfolders after that.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question