VBA FileExists

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

VBA FileExists Syntax

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

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