PDA

View Full Version : Solved: Accessing files inside a zip folder



LLEW1
04-23-2009, 07:18 PM
Hi, looking for help on this - just need VB command lines to execute opening a zip file containing XML files, and move to a new folder location.

The context:
A compressed file containing XML files gets created by other processes. These are located on a shared network location.

I need to:
Access the compressed XML files, so I need get the zip file open or to access the XML files.

Im considering a proces of opening the zip file and placing all into a folder location - what is the best method for this or a better solution when dealing with a zip folder.

Any thoughts appreciated....

Dave
04-24-2009, 05:40 PM
HTH. Dave
http://www.vbaexpress.com/forum/showthread.php?t=17357

LLEW1
04-24-2009, 05:59 PM
Tks Dave - checking it out now....

LLEW1
04-24-2009, 06:19 PM
Tks Dave - has helped but getting Expected Identifier error with code below...Im naming incorrectly?



Public Function UnZiptoNewDirectory("C:\TestUnpack.zip" As String, _
"C:\" As String, "TestUnpack.zip" As String)
'unzip folder/file to new directory
' UnZipThatFolder is zipped file name
'eg. Call UnZiptoNewDirectory("F", "C", "Testfolder")
'eg. Call UnZiptoNewDirectory("F", "C", "Test.doc")
Dim Ofsobj As Object, Temp2 As Object
Dim Drv As String, Foldername As String, EDrv As Variant
Drv = StartDrive & ":\" 'starting drive location
EDrv = EndDrive & ":\" 'ending drive location
Foldername = EDrv & UnZipThatFolder 'unzipped folder name
'if unzipped folder already exists then delete
On Error Resume Next
Set Ofsobj = CreateObject("Scripting.FileSystemObject")
Set Temp2 = Ofsobj.getfolder(Foldername)
If Temp2 <> "" Then
Ofsobj.deletefolder (Foldername), False
End If
'unzip file to new directory
Call Unzip(EDrv, Drv & UnZipThatFolder & ".zip")
Set Temp2 = Nothing
Set Ofsobj = Nothing
End Function

Dave
04-25-2009, 04:05 PM
Please review the code/thread comments. Don't change the function...Call it. I'm guessing...

Call UnZiptoNewDirectory("C", "C", "TestUnpack")

The "Unzip" sub is also critical. Dave
edit: code change

LLEW1
04-26-2009, 03:50 AM
Hi Dave, used above.

have it working now. Thanks again.