ray88’s diary

お仕事で困ったとき用の自分用の覚書

Excel VBA 指定されたファイルパスが存在するか確認する

Function fncIsExistsFile(targetPath As String) As Boolean
'----------------------------------------------------
'機能:指定されたファイルパスが存在するか確認し
'   結果をTrueまたはFalseで返す
'引数1:ファイルパス
'-----------------------------------------------------
     With CreateObject("Scripting.FileSystemObject")
        If .FileExists(targetPath) Then
            fncIsExistsFile = True
        Else
            fncIsExistsFile = False
        End If
    End With
End Function