ChrisAcheson
09-25-2019, 05:04 AM
Hi
I normally use the below code, to find latest published file in folder, and open, which the below works fine.
Sub OpenLatestFile()
c00 = "\\\Output\Chris\"
Workbooks.Open Split(CreateObject("wscript.shell").exec("cmd /c dir """ & c00 & "*"" /b/s/a-d/o-d").stdout.readall, vbCrLf)(0)
End Sub
However, Now, I want to find the latest file within the folder that contains part of the file name.... 'Shopone' for example.
I have tried various things, such as the below ... which does not work for me.
Sub OpenLatestFile()
c00 = "\\\Output\Chris\"
Workbooks.Open Split(CreateObject("wscript.shell").exec("cmd /c dir """ & c00 & "*/shopone"" /b/s/a-d/o-d").stdout.readall, vbCrLf)(0)
End Sub
Is anyone able to advise, where I am going wrong?
Kind regards.
Chris
I normally use the below code, to find latest published file in folder, and open, which the below works fine.
Sub OpenLatestFile()
c00 = "\\\Output\Chris\"
Workbooks.Open Split(CreateObject("wscript.shell").exec("cmd /c dir """ & c00 & "*"" /b/s/a-d/o-d").stdout.readall, vbCrLf)(0)
End Sub
However, Now, I want to find the latest file within the folder that contains part of the file name.... 'Shopone' for example.
I have tried various things, such as the below ... which does not work for me.
Sub OpenLatestFile()
c00 = "\\\Output\Chris\"
Workbooks.Open Split(CreateObject("wscript.shell").exec("cmd /c dir """ & c00 & "*/shopone"" /b/s/a-d/o-d").stdout.readall, vbCrLf)(0)
End Sub
Is anyone able to advise, where I am going wrong?
Kind regards.
Chris