Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DOES FILE EXIST

132 views
Skip to first unread message

Gary

unread,
Mar 3, 2003, 3:18:45 PM3/3/03
to
Hi there,

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

Harald Staff

unread,
Mar 3, 2003, 3:40:20 PM3/3/03
to
Hi 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...

Bob Kilmer

unread,
Mar 4, 2003, 12:11:59 AM3/4/03
to
Option Explicit

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...

0 new messages