I am using the following Function to retrieve the newest file in a folder. This is working fine.
However, I need to modify this function so that it will find the newest file in a folder where the file name contains "Alert". Any help would be appreciated.
Thanks
Accel45
Function Main()
Dim oFolder
Set oFolder = CreateObject("scripting.filesystemobject").getfolder("c:\test")
For Each aFile In oFolder.Files
If sNewest = "" Then
Set fNewest = aFile
sNewest = aFile.Name
Else
If fNewest.DateCreated < aFile.DateCreated Then
Set fNewest = aFile
End If
End If
Next
Me.Text1 = fNewest.Name
End Function
However, I need to modify this function so that it will find the newest file in a folder where the file name contains "Alert". Any help would be appreciated.
Thanks
Accel45
Function Main()
Dim oFolder
Set oFolder = CreateObject("scripting.filesystemobject").getfolder("c:\test")
For Each aFile In oFolder.Files
If sNewest = "" Then
Set fNewest = aFile
sNewest = aFile.Name
Else
If fNewest.DateCreated < aFile.DateCreated Then
Set fNewest = aFile
End If
End If
Next
Me.Text1 = fNewest.Name
End Function