I need a generic function that I can use to retrieve the modified date of a file. Here’s my best shot and it gives me the error, “Object variable or with block variable not set”. It stops at line, Set objFolderItem = objFolder.ParseName(strFilename) which confuses me because it holds the correct value.
Public Function GetFileModDate(strFolder As String, strFilename As String)
Dim strValue As Date
strFolder = “Ppnta661PAGroupTOSTop Technical ServicesSpecial Asset Reports”
strFilename = “REALEST.txt”
Set objShell = CreateObject(“Shell.Application”)
Set objFolder = objShell.NameSpace(strFolder)
Set objFolderItem = objFolder.ParseName(strFilename)
strValue = objFolder.GetDetailsOf(objFolderItem, 3)
If strValue <= Date – 7 Then
MsgBox "The file is not current"
Else
MsgBox "The file is Current"
End If
End Function