|
大家好 !
本人使用EXCEL2003 想透過VBA 找 路徑內 某幾種副檔名 但只能弄到一種 請問大大有什麼法子嗎
Sub xls_txt_cmf_dir()
Dim sFolder As String
Dim wb As Workbook
If Range("b1") = "" Then
MsgBox ("Nothing Path")
GoTo quit
End If
With Application.FileSearch
path = Range("b1")''''''''''''''''''''''''''我想要副檔名的路徑
FileType = Range("b2")''''''''''''''''''我想要的檔名是.... 一般只有一種副檔名 比如.TXT 我想同時要.XLS .TXT.CMD的副檔名 一起找到
t = 6
.NewSearch
.LookIn = path
.SearchSubFolders = True
.Filename = FileType
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
On Error Resume Next
Cells(t, 2) = .FoundFiles(i)
t = t + 1
Next i
Else
MsgBox "Folder " & sFolder & " contains no CheckList files"
End If
End With
求大大幫忙!
quit:
End Sub |
|