• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Get the Modified DateTime of a certain file in a .zip file

inddon

Member
Hello There,

I have a requirement to create a VBA function to return the modifed date time of a specific file in the specific folder of a .zip file.

The parameters provided as follows:
1. Folder Path (Path --> C:\)
2. Name of the .zip file (complete folder path including zip file name --> FolderFile.zip)
3. Name of the sub directory in the .zip (where the file's date time is to be known --> Folder3)
4. Name of the file (from step 3 --> folder3 Myfile3.csv)

Attached the sample zip file for your reference.

My previous post related to the zip file, solution provided by @Marc L :
https://chandoo.org/forum/threads/extract-a-specific-file-from-a-zip-file-search-for-a-string-if-it-exists-in-the-extracted-file.45806/#post-272907


Thank you and looking forward to hearing from you.

Regards,
Don
 

Attachments

Marc L

Excel Ninja
Hi !​
Microsoft Shell Controls And Automation reference must be activated …​
Code:
Function ZipFDT(ZP$, ZF$, EP$, EF$) As Date
         On Error Resume Next
    With New Shell
         ZipFDT = .Namespace(ZP & "\" & ZF).Items.Item(IIf(EP > "", EP & "\" & EF, EF)).ModifyDate
    End With
End Function
Notice it can be achieved with only 2 parameters rather than 4 :​
Code:
Function ZipFDT(Z$, F$) As Date
        On Error Resume Next
    With New Shell
        ZipFDT = .Namespace(Z).Items.Item(F).ModifyDate
    End With
End Function
Do you like it ? So thanks to click on bottom right Like !​
 

Marc L

Excel Ninja
The late binding variation so without activating any reference but requiring the variables used with Shell as Variant​
(here via ParseName instead of Items.Item) :​
Code:
Function ZipFDT(Z, F) As Date
         On Error Resume Next
         ZipFDT = CreateObject("Shell.Application").Namespace(Z).ParseName(F).ModifyDate
End Function
You may Like it !​
 

inddon

Member
The late binding variation so without activating any reference but requiring the variables used with Shell as Variant​
(here via ParseName instead of Items.Item) :​
Code:
Function ZipFDT(Z, F) As Date
         On Error Resume Next
         ZipFDT = CreateObject("Shell.Application").Namespace(Z).ParseName(F).ModifyDate
End Function
You may Like it !​

Thank you Marc
 
Top