[英]How to get the last modified file in a directory using VBA in Excel 2010
[英]VBA - How to get the last modified file or folder in a directory in Excel 2010
我想做的比從文件列表中選擇文件更復雜。 我將從一個目錄開始,然后我想切換到最近修改的目錄。 然后我想在一個子目錄中重復該過程,然后在其中,我想 select 最近修改的 excel 文件並打開它。
做到這一點的最佳方法是什么?
我應該研究哪些對象/方法?
最簡單的 function 是
FileDateTime(pathname)
其中 pathname 可以是文件夾的目錄。
或者,您可以使用 FileSystemObject object, DateLastModified 屬性:
Dim fileModDate As String
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(<filenamestringhere>)
fileModDate = f.DateLastModified
以上所有內容都可以在 VBA 幫助中進行探索。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.