Consulting

Results 1 to 6 of 6

Thread: Solved: Accessing files inside a zip folder

  1. #1
    VBAX Regular
    Joined
    Feb 2009
    Posts
    38
    Location

    Solved: Accessing files inside a zip folder

    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....

  2. #2

  3. #3
    VBAX Regular
    Joined
    Feb 2009
    Posts
    38
    Location
    Tks Dave - checking it out now....

  4. #4
    VBAX Regular
    Joined
    Feb 2009
    Posts
    38
    Location

    Accessing files inside a Zip folder - referred suggestion

    Tks Dave - has helped but getting Expected Identifier error with code below...Im naming incorrectly?


    [VBA]
    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 [/VBA]

  5. #5
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    836
    Location
    Please review the code/thread comments. Don't change the function...Call it. I'm guessing...
    [vba]
    Call UnZiptoNewDirectory("C", "C", "TestUnpack")
    [/vba]
    The "Unzip" sub is also critical. Dave
    edit: code change
    Last edited by Dave; 04-25-2009 at 05:18 PM.

  6. #6
    VBAX Regular
    Joined
    Feb 2009
    Posts
    38
    Location
    Hi Dave, used above.

    have it working now. Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •