' '指定したフォルダのファイル名、サイズ、パス名をExcelファイルに書き出す ' ' ' Dim myFolder, newFolder,newName myFolder = InputBox("調べるフォルダ","Folder","R:\警視庁cad") newFolder = InputBox("結果をセーブするフォルダ","Folder","R:\警視庁cad") newName = InputBox("結果を出力するファイル","Folder","list") Dim myExcel, myBook, FS, objFolder, myRows Set myExcel = Wscript.CreateObject("Excel.Application") myExcel.Visible = TRUE Set mybook = myExcel.WorkBooks.Add set FS = createObject("Scripting.FileSystemObject") Set objFolder = FS.GetFolder(myFolder) myExcel.Cells(1, 1).ColumnWidth = 15 myExcel.Cells(1, 2).ColumnWidth = 10 myExcel.Cells(1, 3).ColumnWidth = 35 myExcel.Cells(1, 4).ColumnWidth = 35 myExcel.Cells(1, 5).ColumnWidth = 10 myExcel.Cells(1, 6).ColumnWidth = 10 myExcel.Cells(1, 1).Value = "ファイル名" myExcel.Cells(1, 2).Value = "サイズ" myExcel.Cells(1, 3).Value = "パス" myExcel.Cells(1, 4).Value = "Folder" myExcel.Cells(1, 5).Value = "Type" myExcel.Cells(1, 6).Value = "Date" myRows = 2 Call checkFile(objFolder) Sub checkFile(objFolder) For Each objFile In objFolder.Files myExcel.Cells(myRows, 1).Value = objFile.Name myExcel.Cells(myRows, 2).Value = objFile.Size myExcel.Cells(myRows, 3).Value = objFile.Path myExcel.Cells(myRows, 4).Value = objFile.ParentFolder myExcel.Cells(myRows, 5).Value = objFile.Type myExcel.Cells(myRows, 6).Value = objFile.DateCreated myRows = myRows + 1 myExcel.Cells(myRows, 1).Select Next For Each objSubFolder In objFolder.SubFolders Call checkFile(objSubFolder) Next End Sub If Right(svName,5) <> ".xlsx" then newName = newName & ".xlsx" End If If Right(newFolder,1)<>"\" then newFolder = newFolder & "\" End IF myBook.SaveAs(newFolder & newName) myExcel.Quit