Determine if a workbook exists

 1999-12-20    Workbooks    0    85

The function below can be used to determine if a workbook or another file exists:

Function FileExists(FullFileName As String) As Boolean
' returns TRUE if the file exists
    FileExists = Len(Dir(FullFileName)) > 0
End Function

If Not FileExists("C:\FolderName\SubFolder\FileName.xls") Then 
    MsgBox "The file doesn't exist!"
    Workbooks.Open "C:\FolderName\SubFolder\FileName.xls"
End If

Leave a comment:

Your comment will only be published after it has been moderated and found spam free.
Your e-mail address will only be used to display your Gravatar.