PDA

View Full Version : Open Zip file with many other named files and months within folder



ChrisAcheson
03-03-2017, 03:22 AM
Hi All

I have asked a similar question previously, which that code works fine for that requirement.


sn = Array("\\\All\", "\\\All\", "") ' source directory / destination directory

sn(2) = sn(0) & Split(CreateObject("wscript.shell").exec("cmd /c dir """ & sn(0) & "*.zip"" /b/o-d").stdout.readall, vbCrLf)(0)


With CreateObject("Shell.Application")
.Namespace(sn(1)).CopyHere .Namespace(sn(2)).Items.Item(0)
sn(2) = sn(1) & .Namespace(sn(2)).Items.Item(0)
End With

Workbooks.Open sn(2)



However I am wanting to either extend the above code or adapt it to meet the following requirement ..

To find the latest CSV file that contains the word 'Position' within 2/3 levels of folder heirachy.

The current Heirachy is as follows ...


C:\Reports\Daily Reports

Then months

Jan
Feb
March


So ideally I would like the code to search for 'pos' in March (but obviously march could be any month, and i want to search the latest file) and then open that Pos file.


Any help is greatly appreciated.

Thank you.