Retrieve textfile properties of file in zipfolder

Dato

New Member
Joined
Feb 23, 2020
Messages
1
Office Version
  1. 2013
Platform
  1. Windows
Dear all,

I wrote a VBA macro (partly mine and partyl snippets from the Internet) that lists all files that are contained in all zip files the macro can find in the starting path:

VBA Code:
folder_path = "C:\Users\[MYNAME]\Desktop\prod".

This works. It runs through every Folder down to zipArchive which contains multiple zip files with multiple files (no further Folders) within those zip file. I started to let the macro write down some Information about those files such as Name, size,...
NOW the reason I am doing this is that I am interested in the creation date/last modification date of the files within each zip file. So I used

VBA Code:
Range("B" & i).Value = fileNameInZip.DateCreated

which returns an error saying that the object does not support the method or property…
Thinks like Name and size work somehow

Can someone help out on this?

VBA Code:
Private Sub Get_Information3()   
 folder_path = "C:\Users\[MYNMAME]\Desktop\prod"   
 Dim sh As Worksheet   
 Set sh = ThisWorkbook.Sheets("Tabelle1")  
  Dim oFSO As Object    Dim oFolder As Object 'prod 
   Dim oSubFolderSupplier As Object 'Supplier    Dim oSubFolderCountry As Object  
  Dim oSubFolderDatabase As Object   
 Dim oSubFolderZipArchive As Object    
Dim oFileinZipArchive As Object   
 Dim last_row As Integer   
 Dim oApp As Object    

Set oFSO = CreateObject("Scripting.FileSystemObject")  
Set oFolder = oFSO.GetFolder(folder_path)   
 Set oApp = CreateObject("Shell.Application")  
 
Dim i, r As Integer    Dim fileNameInZip As Variant   
Dim Fname As Variant    Dim sh1 As Worksheet    

Set sh = ThisWorkbook.Sheets("Tabelle1")    

Dim Stringtest As Integer    
Dim test1 As String   

 i = 2    
For Each oSubFolderSupplier In oFolder.SubFolders        
    For Each oSubFolderCountry In oSubFolderSupplier.SubFolders
            For Each oSubFolderDatabase In oSubFolderCountry.SubFolders 
               For Each oSubFolderZipArchive In oSubFolderDatabase.SubFolders
                    For Each oFileinZipArchive In oSubFolderZipArchive.Files
                         Fname = Dir(oFileinZipArchive)
                        Stringtest = InStrRev(oFileinZipArchive, "\")
                        test1 = Left(oFileinZipArchive, Stringtest)
                        If Right(Fname, 4) = ".zip" Then
                              For Each fileNameInZip In oApp.Namespace(test1 & Fname).Items
                             Range("A" & i).Value = fileNameInZip.Name
                             Range("B" & i).Value = fileNameInZip.DateCreated
                            i = i + 1
                              Next
                         End If
                    Next 
               Next
            Next 
       Next
    Next 
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Does it absolutely have to be the Creation Date? I checked, and the ModifyDate property is accessible. I suppose it depends on what you need the date for - most of my work uses the Modification Date more than any other.

If it does need to be the dateCreated property, then - it's a bit of a hack - copy the individual file out of the ZIP file, and then check the dateCreated property with FileSystemObject.
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top