P peggypph Registered User. Local time Today, 21:22 Joined Jan 2, 2004 Messages 33 Jan 9, 2004 #1 I would like to have a routine to check file existence under VBA. Pls. give me some example. Thanks
=TB= Registered User. Local time Today, 13:22 Joined Aug 13, 2002 Messages 68 Jan 9, 2004 #2 Code: Dim fLen As Integer, filepath As String filepath = "c:\SomeFile.txt" On Error Resume Next fLen = Len(Dir$(filepath)) If Err Or fLen = 0 Then MsgBox ("The File Does Not Exist") Else MsgBox ("The File Does Exist") End If Is this what you are after?
Code: Dim fLen As Integer, filepath As String filepath = "c:\SomeFile.txt" On Error Resume Next fLen = Len(Dir$(filepath)) If Err Or fLen = 0 Then MsgBox ("The File Does Not Exist") Else MsgBox ("The File Does Exist") End If Is this what you are after?
ghudson Registered User. Local time Today, 08:22 Joined Jun 8, 2002 Messages 6,193 Jan 9, 2004 #3 Code: If Dir("C:\Temp\testing.txt") <> "" Then MsgBox "File does exist." Else MsgBox "File does not exist." End If
Code: If Dir("C:\Temp\testing.txt") <> "" Then MsgBox "File does exist." Else MsgBox "File does not exist." End If