Open the workbook if exists in the path

    Click On below mentioned image to watch the video:

     

     

     

    Option Explicit

    Sub OpenTheWorkbookIfExists()

    'Create a variable for File System Object
    Dim FSO As Scripting.FileSystemObject
    Set FSO = New Scripting.FileSystemObject

    'Define Filepath
    Dim FilePath As String
    FilePath = "C:\Test\Samples.xlsx"

    'Open the workbook if exists in the defined path
    If FSO.FileExists(FilePath) = True Then
    Workbooks.Open (FilePath)

    Else:
    MsgBox "Workbook doesn't exists in the below mentioned path" & vbNewLine & FilePath
    End If

    End Sub

    DownLoad The Workbook