Sub XQ_fileOB()
Dim ma As Long, myFile
Dim FolderDialogObject As FileDialog
Set FolderDialogObject = Application.FileDialog(msoFileDialogFolderPicker)
With FolderDialogObject
.Title = "請選擇要查找的文件夾"
.InitialFileName = "C:\"
End With
FolderDialogObject.Show
paths = FolderDialogObject.SelectedItems(1)
mypath = paths & "\"
ipath = Dir(mypath & "*.*") '可以使用通配符酷宵,輸出所有xls 和 xlsx 文件
myFile = Dir(mypath, vbDirectory)
a = 1
Do While myFile <> ""
If myFile <> "." And myFile <> ".." Then
Cells(a, 1) = myFile
Cells(a, 2) = mypath & myFile
a = a + 1
myFile = Dir
Else
myFile = Dir
End If
Loop
End Sub