■呼び出し先プロシージャ
Sub test() Dim folderPath As String Dim Result As Boolean folderPath = "C:\Users\デスクトップ\テスト\テストフォルダ" If IsExistsDir(folderPath) Then MsgBox "フォルダは存在します" Else MsgBox "フォルダは存在しません" End If End Sub
■ファンクションプロシージャ
Function IsExistsDir(targetPath As String) As Boolean '---------------------------------------------------- '機能:指定されたフォルダパスが存在するか確認し ' 結果をTrueまたはFalseで返す '引数1:フォルダパス '----------------------------------------------------- With CreateObject("Scripting.FileSystemObject") If .FolderExists(targetPath) Then IsExistsDir = True Else IsExistsDir = False End If End With End Function