Set fso = CreateObject("Scripting.FileSystemObject")
Set froot = fso.GetFolder(strstartfldr)
For Each fldr In froot.SubFolders
UserForm1.ComboBox1.AddItem fldr.DateCreated
Next
在这个程序中我可以获取combbobox1中的子文件夹列表 但从这个子文件夹我怎么知道哪个是最后修改的文件夹名称 我确信有简单的代码,但无法弄清楚
有谁帮忙
代码
Option Explicit
Function LastFolder(FolderPath As String) As String
Dim fso As Object
Dim froot As Object
Dim fldr As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set froot = fso.GetFolder(FolderPath)
Dim fName As String
Dim fDC As Date
Dim TMP As Date
For Each fldr In froot.subfolders
TMP = fldr.DateCreated
If TMP > fDC Then
fDC = TMP
fName = fldr.Name
End If
Next fldr
LastFolder = fName
End Function
Sub testLastFolder()
Debug.Print LastFolder("F:\StackOverFlow")
End Sub