|
とあるサイトから入力したアドレスのフォルダ内にあるファイル名を
エクセルにリストアップするマクロを入手したんですが、
これに、更新日時とサイズを記載する方法はありますか?
Private Sub CommandButton1_Click()
Const cnsTITLE = "List file name in the folder"
Const cnsDIR = "\*.*"
Dim xlAPP As Application
Dim strPATHNAME As String
Dim strFILENAME As String
Dim GYO, i As Long
Set xlAPP = Application
strPATHNAME = xlAPP.InputBox("Input folder address.", cnsTITLE, "C:\")
If StrConv(strPATHNAME, vbUpperCase) = "FALSE" Then Exit Sub
'check input
If Dir(strPATHNAME, vbDirectory) = "" Then
MsgBox "There is no input folder.", vbExclamation, cnsTITLE
Exit Sub
End If
Workbooks.Add
Range("A1") = "No."
Range("B1") = "File name"
Range("A2:B65536") = ""
GYO = 2
'get top file name
strFILENAME = Dir(strPATHNAME & cnsDIR, vbNormal)
Do While strFILENAME <> ""
Cells(GYO, 1) = GYO - 1
Cells(GYO, 2).Value = strFILENAME
strFILENAME = Dir()
GYO = GYO + 1
Loop
Columns("A:B").Select
Columns("A:B").EntireColumn.AutoFit
End Sub
|
|