I'm trying to develop a bit of VBA that will check the date modified section on the file. I have found a bit of code online that uses the FileSystemObject to do this, but I run into a "Type Mismatch" error in VBA and was hoping someone could help..
Sub test()
Dim FileLastModified As Variant
MsgBox FileLastModified("S:\FILEPATHISHERE.xls")
End Sub
(naturally i have entered the actual filepath there!)
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 have just added the Microsoft Scripting Runtime Reference, but this is still not working. Any ideas? Am I missing other required references?
Thanks in advance
Alex
以上就是VBA Excel File System Object的详细内容,更多请关注web前端其它相关文章!