Ok. I'm now trying to write an IF statement to say something to the effect of: If file is more than 5 days old, do not run macro. If more than 5 days old, run macro. I would like to this to be a yes or no dialogue box. Here is my code. Please help. I'm still trying to learn this vba code.
Sub LastModifiedFile()
'Function FileLastModified(strFullFileName As String) Dim fs As Object, f As Object, s As String, dtmodpath As String
dtmodpath = "\\jdshare\pdcmaterials\5_Tools\FTP\Cancelled_Report.txt"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(dtmodpath)
's = UCase(strFullFileName) & vbCrLf
s = f.DateLastModified
FileLastModified = s
Set fs = Nothing: Set f = Nothing
Range("E5").Value = FileLastModified
'If FileExists(strFullName) Then 'MsgBox FileLastModified(strFullName) 'Else 'MsgBox "File Older than 5 Years : " & vbNewLine & strFullName 'End If
'End Function
End Sub
Aucun commentaire:
Enregistrer un commentaire