简体   繁体   中英

How to open the last file of a folder in a SharePoint using VBA?

I would like to ask help on creating commands which will be able to open ONLY the latest file of a folder in a SharePoint using VBA. Your prompt response is greatly appreciated. Many thanks!

If you use the shell command Dir (not the VBA command dir) you can sort the files according to date ( /od ) . If you use a descending sort the first file will be the most recent.

Sub M_snb()
  msgbox split(createobject("wscript.shell").exec("cmd /c Dir G:\OF\*.* /b /o-d").stdout.readall,vbcrlf)(0)
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM