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

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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,224,817
Messages
6,181,147
Members
453,021
Latest member
Justyna P

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