ray88’s diary

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

Excel VBA フォルダパスの有無を確認する

Function fncIsExistsDir(targetPath As String) As Boolean
'----------------------------------------------------
'機能:指定されたフォルダパスが存在する
'引数1:フォルダパス
'戻り値:フォルダの有無をTrueかFalseで返す
'-----------------------------------------------------
     With CreateObject("Scripting.FileSystemObject")
        If .FolderExists(targetPath) Then
            fncIsExistsDir = True
        Else
            fncIsExistsDir = False
        End If
    End With
End Function