Re: VBA to expose details of zip files

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



That is correct. It doesn't find it until much later in the file.
Stepping through it probably isn't what you want to do.

Look at Tim William's example which should work for Millenium and Windows
XP.

--
Regards,
Tom Ogilvy



"Chris Jones" <ChrisJones@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0D3DBC81-0196-4FD3-8AC0-E154557EBC6F@xxxxxxxxxxxxxxxx
> 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 work*** 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" <ChrisJones@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > news:FEF49981-A620-4224-826A-2AAABAED64A9@xxxxxxxxxxxxxxxx
> > > 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" <ChrisJones@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
> > > > > news:CE250FCD-2CF7-427A-BE69-DD61BE30CB48@xxxxxxxxxxxxxxxx
> > > > > > 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
> > > > > >
> > > > >
> > > > >
> > > > >
> >
> >
> >


.


Quantcast