' テスト用関数 Sub test_exDirExist() Dim strDir As String strDir = "c:\Windows" If exDirExist(strDir) = True Then Debug.Print "存在" Else Debug.Print "存在しない" End If End Sub '**************************************************************************************************** ' ---------------------------------------------------------------------------------------------- ' MINDKERNEL.COM 2013/10/18 ' ---------------------------------------------------------------------------------------------- ' '【名 称】ディレクトリの存在チェック '【機 能】ディレクトリが存在するか調べる。 ' ※※Dir関数にvbDirectoryオプションを付けているが、(属性がない)ファイルの場合もファイル名を返却する。 '【関数名】exDirExist() '【引 数】String PathName (IN) : ディレクトリのフルパス '【戻り値】Boolean TRUE : 存在する ' FALSE : 存在しない '【履 歴】 ' 2013/10/18 新規 '*************************************************************************************************** Public Function exDirExist(PathName As String) As Boolean Dim ret As Boolean: ret = False '引数チェック If PathName = "" Then GoTo EndError End If 'ディレクトリの存在チェック If Dir(PathName, vbDirectory) = "" Then ret = False Else ret = True End If EndNormal: exDirExist = ret Exit Function EndError: exDirExist = False Exit Function End Function