The FileSystemObject VBA FileExists function returns True if the file exists otherwise will return False.
- BuildPath
- CopyFile
- CopyFolder
- CreateFolder
- CreateTextFile
- DeleteFile
- DeleteFolder
- DriveExists
- FileExists
- FolderExists
- GetAbsolutePathName
- GetBaseName
- GetDrive
- GetDriveName
- GetExtensionName
- GetFile
- GetFileName
- GetFolder
- GetParentFolderName
- GetSpecialFolder
- GetTempName
- MoveFile
- MoveFolder
- OpenTextFile
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 |