Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Opening files and folders with details | Excel Discussion (Misc queries) | |||
Excel: Expose whole window or at least top resize handles. | Excel Discussion (Misc queries) | |||
Issue with Details View when opening files in Excel, Word, etc. | Excel Discussion (Misc queries) | |||
Expose macros with add-in | Excel Programming | |||
Searching for link: Bob Phillips expose on NAMES | Excel Programming |