- ©«¤l
- 7
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 11
- ÂI¦W
- 0
- §@·~¨t²Î
- Win10
- ³nÅ骩¥»
- Office 2021
- ¾\ŪÅv
- 50
- ©Ê§O
- ¤k
- µù¥U®É¶¡
- 2010-8-22
- ³Ì«áµn¿ý
- 2024-3-31
|
¦^´_ 1# millerch
ɥΠsamwang ¿ï¨ú dir ³¡¥÷
¦C¥X§A·Qnªº xlsm ÀÉ- Private fso As Object
- Public Sub ListAllXlsmFiles()
- Dim foundFiles As New Collection
- Dim foundFile As Variant
- Dim DirPath As String
- Set fso = CreateObject("Scripting.FileSystemObject")
- Range("A1").Select
- With Application.FileDialog(msoFileDialogFolderPicker)
- .InitialFileName = "G:\"
- .Title = "======= ¿ï¾Ü¸ê®Æ§¨ ========"
- .Show
- On Error GoTo EndSub
- DirPath = .SelectedItems(1)
- End With
- FindAllFiles DirPath, "xlsm", foundFiles
- For Each foundFile In foundFiles
- With ActiveCell
- .Value = foundFile
- .Offset(1, 0).Select
- End With
- Next foundFile
- EndSub:
- End Sub
- Private Sub FindAllFiles(parentFolder As String, extension As String, foundFiles As Collection)
- Dim thisFolder As Object
- Dim subFolder As Object
- Dim thisFile As Object
- Dim testObject As Object
- On Error Resume Next
- Set thisFolder = fso.GetFolder(parentFolder)
- Err.Clear
- Set testObject = thisFolder.Files
- If Err.Number = 0 Then
- For Each thisFile In thisFolder.Files
- If LCase(thisFile.Name) Like "*." & LCase(extension) Then
- foundFiles.Add thisFile.Path
- End If
- Next thisFile
- End If
- Err.Clear
- Set testObject = thisFolder.SubFolders
- If Err.Number = 0 Then
- For Each subFolder In thisFolder.SubFolders
- FindAllFiles subFolder.Path, extension, foundFiles
- Next subFolder
- End If
- End Sub
½Æ»s¥N½X |
|