Hi there,
See if the following code does what you want:
Sub ClearOldFiles()
Dim bFileExists As Boolean
Dim sFolderName As String
Dim vaFileName As Variant
sFolderName = "W:\"
bFileExists = True
vaFileName = Dir$(sFolderName, vbNormal)
While bFileExists = True
If vaFileName = vbNullString Then
bFileExists = False
Else
If Int(FileDateTime(sFolderName & vaFileName)) < Date Then
Kill sFolderName & vaFileName
End If
vaFileName = Dir
End If
Wend
End Sub
Change the highlighted value to suit your own requirements.
Strictly speaking, you don't need this part of the above code, but I had already included it because I wanted to extract the Date part of the value for testing.
Hope this helps - please let me know how you get on.
Regards,
Greg M
Bookmarks