Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in message
...
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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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" wrote in message
...
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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default 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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening files and folders with details Darlene Excel Discussion (Misc queries) 3 October 11th 09 09:23 PM
Excel: Expose whole window or at least top resize handles. Reinie Excel Discussion (Misc queries) 1 August 25th 09 04:11 PM
Issue with Details View when opening files in Excel, Word, etc. JrCT040 Excel Discussion (Misc queries) 1 July 26th 09 08:24 AM
Expose macros with add-in Dave Stice Excel Programming 6 January 30th 06 05:50 PM
Searching for link: Bob Phillips expose on NAMES davidm Excel Programming 2 January 28th 06 08:10 AM


All times are GMT +1. The time now is 04:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"