Extract all Files from a Zip but not any folders

Posted on 2014-03-05
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 35

Assisted Solution

Kimputer earned 500 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:\scowebreports\reports\FB6122\2014068\  then the text files.  The last folder 2014068 changes daily.
LVL 35

Accepted Solution

Kimputer earned 500 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

738 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