Solved

Extract all Files from a Zip but not any folders

Posted on 2014-03-05
3
285 Views
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
0
Comment
Question by:Hiken
  • 2
3 Comments
 
LVL 35

Assisted Solution

by:Kimputer
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, "*.*"
    oApp.Namespace(unZipToLoc).CopyHere(FilesInZip)
     
End Function

Open in new window

0
 

Author Comment

by:Hiken
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.
0
 
LVL 35

Accepted Solution

by:
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now