VBA FileExists

The FileSystemObject VBA FileExists function returns True if the file exists otherwise will return False.

VBA FileExists Syntax

1
fso.FileExits( filepath )

filepath
A string representing path to the file.

VBA FileExists Examples

Below examples assume file “C:\Src\Hello.txt” exists and no other files exist in the folder “C:\Src”.

1
2
3
4
5
Set fso = CreateObject("Scripting.FileSystemObject")
 
Debug.Print fso.FileExists("C:\Src\Hello.txt") 'Result: True
 
Debug.Print fso.FileExists("C:\Src\Goodbye.txt") 'Result: False