+ Reply to Thread
Results 1 to 8 of 8

VBA to expose details of zip files

Hybrid View

  1. #1
    Chris Jones
    Guest

    VBA to expose details of zip files

    I have a directory of zip files which I want to calculate the (gross) file
    size of. Does anyone here know of a way to expose this information using VBA?

    --
    Chris Jones


  2. #2
    Tom Ogilvy
    Guest

    Re: VBA to expose details of zip files

    Do you want the collective size of the zip files or the uncompressed size of
    the files they contain?

    What version of Windows?

    --
    Regards,
    Tom Ogilvy


    "Chris Jones" <[email protected]> wrote in message
    news:[email protected]...
    > I have a directory of zip files which I want to calculate the (gross) file
    > size of. Does anyone here know of a way to expose this information using

    VBA?
    >
    > --
    > Chris Jones
    >




  3. #3
    Chris Jones
    Guest

    Re: VBA to expose details of zip files

    Tom,

    I am after the total uncompressed size of the zip files contained in the
    archive.
    --
    Chris Jones



    "Tom Ogilvy" wrote:

    > Do you want the collective size of the zip files or the uncompressed size of
    > the files they contain?
    >
    > What version of Windows?
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Chris Jones" <[email protected]> wrote in message
    > news:[email protected]...
    > > I have a directory of zip files which I want to calculate the (gross) file
    > > size of. Does anyone here know of a way to expose this information using

    > VBA?
    > >
    > > --
    > > Chris Jones
    > >

    >
    >
    >


  4. #4
    Chris Jones
    Guest

    Re: VBA to expose details of zip files

    Sorry, I forgot to note that this is running Office 2003 on WindowsXP
    Professional

    --
    Chris Jones



    "Chris Jones" wrote:

    > Tom,
    >
    > I am after the total uncompressed size of the zip files contained in the
    > archive.
    > --
    > Chris Jones
    >
    >
    >
    > "Tom Ogilvy" wrote:
    >
    > > Do you want the collective size of the zip files or the uncompressed size of
    > > the files they contain?
    > >
    > > What version of Windows?
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "Chris Jones" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > I have a directory of zip files which I want to calculate the (gross) file
    > > > size of. Does anyone here know of a way to expose this information using

    > > VBA?
    > > >
    > > > --
    > > > Chris Jones
    > > >

    > >
    > >
    > >


  5. #5
    Tom Ogilvy
    Guest

    Re: VBA to expose details of zip files

    Put a new worksheet in the workbook and make it active

    Then put this code in a new module in the workbook

    Change the filename to point to your file:

    Type FileHeader
    signature As Long
    version_made_by As Integer
    version_needed As Integer
    bitflags As Integer
    comp_method As Integer
    lastModFileTime As Integer
    lastModFileDate As Integer
    crc_32 As Long
    comp_size As Long
    uncompr_size As Long
    fname_len As Integer
    extra_field_len As Integer
    fcomment_len As Integer
    disk_num_start As Integer
    internal_fattribute As Integer
    external_fattribute As Long
    relative_offset As Long
    End Type
    ' char* file_name;
    ' char* extra_field;
    ' char* file_comment;


    Sub GetDir()
    '
    ' Tom Ogilvy
    ' 1/30/2006
    '
    Dim rw As Long
    Dim j As Long, i As Long
    Dim h As FileHeader
    Dim c1 As Byte
    Dim s As String, c As String
    Dim fName as String

    fName = "C:\MyFile.Zip"
    Open fName For Binary As #1
    rw = 1
    i = 1
    Do Until Loc(1) > LOF(1)

    Get 1, i, j
    If j = 67324752 Then
    ElseIf j = 33639248 Then
    Get #1, i, h
    ii = i + 46
    s = ""
    For k = 1 To h.fname_len
    Get #1, ii, c1
    s = s & Chr(c1)
    ii = ii + 1
    Next
    Cells(rw, 1) = s
    Cells(rw, 2) = h.comp_size
    Cells(rw, 3) = h.uncompr_size
    rw = rw + 1
    End If
    i = i + 1

    Loop
    Close #1
    End Sub

    --
    Regards,
    Tom Ogilvy


    "Chris Jones" <[email protected]> wrote in message
    news:[email protected]...
    > Sorry, I forgot to note that this is running Office 2003 on WindowsXP
    > Professional
    >
    > --
    > Chris Jones
    >
    >
    >
    > "Chris Jones" wrote:
    >
    > > Tom,
    > >
    > > I am after the total uncompressed size of the zip files contained in the
    > > archive.
    > > --
    > > Chris Jones
    > >
    > >
    > >
    > > "Tom Ogilvy" wrote:
    > >
    > > > Do you want the collective size of the zip files or the uncompressed

    size of
    > > > the files they contain?
    > > >
    > > > What version of Windows?
    > > >
    > > > --
    > > > Regards,
    > > > Tom Ogilvy
    > > >
    > > >
    > > > "Chris Jones" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > I have a directory of zip files which I want to calculate the

    (gross) file
    > > > > size of. Does anyone here know of a way to expose this information

    using
    > > > VBA?
    > > > >
    > > > > --
    > > > > Chris Jones
    > > > >
    > > >
    > > >
    > > >




  6. #6
    Chris Jones
    Guest

    Re: VBA to expose details of zip files

    Tom,

    I tried to run this against a couple of zip files I have and stepping
    through the code, it never passed the test 'ElseIf j = 33639248 Then'.

    In both zip files the value of j on the second get was 335807307 and not
    33639248.
    --
    Chris Jones



    "Tom Ogilvy" wrote:

    > Put a new worksheet in the workbook and make it active
    >
    > Then put this code in a new module in the workbook
    >
    > Change the filename to point to your file:
    >
    > Type FileHeader
    > signature As Long
    > version_made_by As Integer
    > version_needed As Integer
    > bitflags As Integer
    > comp_method As Integer
    > lastModFileTime As Integer
    > lastModFileDate As Integer
    > crc_32 As Long
    > comp_size As Long
    > uncompr_size As Long
    > fname_len As Integer
    > extra_field_len As Integer
    > fcomment_len As Integer
    > disk_num_start As Integer
    > internal_fattribute As Integer
    > external_fattribute As Long
    > relative_offset As Long
    > End Type
    > ' char* file_name;
    > ' char* extra_field;
    > ' char* file_comment;
    >
    >
    > Sub GetDir()
    > '
    > ' Tom Ogilvy
    > ' 1/30/2006
    > '
    > Dim rw As Long
    > Dim j As Long, i As Long
    > Dim h As FileHeader
    > Dim c1 As Byte
    > Dim s As String, c As String
    > Dim fName as String
    >
    > fName = "C:\MyFile.Zip"
    > Open fName For Binary As #1
    > rw = 1
    > i = 1
    > Do Until Loc(1) > LOF(1)
    >
    > Get 1, i, j
    > If j = 67324752 Then
    > ElseIf j = 33639248 Then
    > Get #1, i, h
    > ii = i + 46
    > s = ""
    > For k = 1 To h.fname_len
    > Get #1, ii, c1
    > s = s & Chr(c1)
    > ii = ii + 1
    > Next
    > Cells(rw, 1) = s
    > Cells(rw, 2) = h.comp_size
    > Cells(rw, 3) = h.uncompr_size
    > rw = rw + 1
    > End If
    > i = i + 1
    >
    > Loop
    > Close #1
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Chris Jones" <[email protected]> wrote in message
    > news:[email protected]...
    > > Sorry, I forgot to note that this is running Office 2003 on WindowsXP
    > > Professional
    > >
    > > --
    > > Chris Jones
    > >
    > >
    > >
    > > "Chris Jones" wrote:
    > >
    > > > Tom,
    > > >
    > > > I am after the total uncompressed size of the zip files contained in the
    > > > archive.
    > > > --
    > > > Chris Jones
    > > >
    > > >
    > > >
    > > > "Tom Ogilvy" wrote:
    > > >
    > > > > Do you want the collective size of the zip files or the uncompressed

    > size of
    > > > > the files they contain?
    > > > >
    > > > > What version of Windows?
    > > > >
    > > > > --
    > > > > Regards,
    > > > > Tom Ogilvy
    > > > >
    > > > >
    > > > > "Chris Jones" <[email protected]> wrote in message
    > > > > news:[email protected]...
    > > > > > I have a directory of zip files which I want to calculate the

    > (gross) file
    > > > > > size of. Does anyone here know of a way to expose this information

    > using
    > > > > VBA?
    > > > > >
    > > > > > --
    > > > > > Chris Jones
    > > > > >
    > > > >
    > > > >
    > > > >

    >
    >
    >


  7. #7
    Tim Williams
    Guest

    Re: VBA to expose details of zip files

    In addition to Tom's solution:

    Sub Tester()
    Dim sPath
    Dim oApp As Object
    Dim x As Integer
    Dim o As Object


    sPath = "U:\backup\Addin Backup 082503.zip"
    Set oApp = CreateObject("Shell.Application")

    For Each o In oApp.NameSpace(sPath).Items
    Debug.Print o.Name & " ---- " & o.Size
    Next o

    Set oApp = Nothing

    End Sub

    --
    Tim Williams
    Palo Alto, CA


    "Chris Jones" <[email protected]> wrote in message
    news:[email protected]...
    > I have a directory of zip files which I want to calculate the (gross) file
    > size of. Does anyone here know of a way to expose this information using

    VBA?
    >
    > --
    > Chris Jones
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1