Excel VBA File System Object
I am trying to develop a VBA bit that will check the modified date section in a file. I found a bit of code on the internet that uses FileSystemObject to do this, but I ran into a "Mismatch Type" error in VBA and hoped someone could help.
Sub test() Dim FileLastModified As Variant MsgBox FileLastModified("S:\FILEPATHISHERE.xls") End Sub
(of course I entered the actual file path!)
Function FileLastModified(strFullFileName As String) Dim fs As Object, f As Object, s As String Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFile(strFullFileName) s = UCase(strFullFileName) & vbCrLf s = s & "Last Modified: " & f.DateLastModified FileLastModified = s Set fs = Nothing: Set f = Nothing End Function
I just added a Microsoft Scripting Runtime link, but that still doesn't work. Any ideas? Am I missing other required links?
Thanks in advance Alex
source to share