If you’re automating your analyses and it involves downloading reports, you’ll need a way to check the download is done. That’s where FileExists comes in handy.
FileExists
Function FileExists(PathToFile As String) As Boolean
If Dir(PathToFile) <> "" Then
FileExists = True
Else
FileExists = False
End If
End Function
Parameter | Description |
---|---|
PathToFile | This is the path to a file you’re looking to evaluate whether it exists. |
Examples
=FileExists("C:\Users\AHavas\Downloads\My Report.xlsx")
If you place the above formula into cell A1, that cell shows TRUE if My Report.xlsx is in the Downloads folder and shows FALSE if it is not.
=FileExists("C:\Users\AHavas\Downloads\My Report*")
You can use the wildcard * to check if any Downloaded file that starts with My Report has been downloaded.
=FileExists("C:\Users\AHavas\Downloads\")
Although this Microservice is named FileExists, you can use it to check if a folder exists.
If you place the above formula into cell A3, that cell shows TRUE because the Downloads folder SHOULD exist in Windows.