I am looking for some VB code to test if a file exists.
I am also looking for some code that can provide me with
the date stamp on a file (not the file I am working in).
Hope some one can help.
Gary
Dir("C:\Temp\Book1.xls")
returns "" if it doesn't exist, "Book1.xls" if it does. And causes trouble
if the folder doesn't.
Filedatetime("C:\Temp\Book1.xls")
returns the date stamp.
There are more sophisticated methods for both, but these serve me fine 95%
of the time.
HTH. Best wishes Harald
"Gary" <gbu...@bigpond.net.au> wrote in message
news:058001c2e1c2$17afafd0$3301...@phx.gbl...
Sub Main()
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
With fso
If .FileExists("T:\SomeFile.txt") Then
With .GetFile("T:\SomeFile.txt")
MsgBox "T:\SomeFile.txt" & vbNewLine & _
"Created: " & .DateCreated & vbNewLine & _
"Accessed: " & .DateLastAccessed & vbNewLine & _
"Modified: " & .DateLastModified
End With
End If
End With
End Sub
"Gary" <gbu...@bigpond.net.au> wrote in message
news:058001c2e1c2$17afafd0$3301...@phx.gbl...