Solved

Extract all Files from a Zip but not any folders

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

713 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