Sub ListFilesInFolder(folderPath As String)
Dim fso As Variant
Dim folder As Variant
Dim file As Variant
' FileSystemObject を作成
Set fso = CreateObject("Scripting.FileSystemObject")
' 指定フォルダを取得
If fso.FolderExists(folderPath) Then
Set folder = fso.GetFolder(folderPath)
' フォルダ内のすべてのファイルを列挙
For Each file In folder.Files
Print file.Path ' ファイルのフルパスを表示
Next
Else
Print "フォルダが存在しません: " & folderPath
End If
' 解放
Set file = Nothing
Set folder = Nothing
Set fso = Nothing
End Sub