zerocoldtn
Thành viên hoạt động
- Tham gia
- 2/6/16
- Bài viết
- 148
- Được thích
- 7
Bạn sửa lại vầy:- File đính kèm bị lỗi như thế nào xin các AC chỉ giáo!
Private Sub ListFilesInFolder(FolderName As String, InSub As Boolean)
Dim FileItem As Object
Dim SubFolder As Object
Dim FileName As String
On Error GoTo ExitSub
Set FileItem = CreateObject("Scripting.FileSystemObject")
With FileItem
For Each FileItem In .GetFolder(FolderName).Files
' If .GetExtensionName(FileItem.Path) = myFile.Path Then
With Range("A65536").End(xlUp)
With .Offset(1, 0)
.Value = FileItem.Path
.Parent.Hyperlinks.Add .Cells, .Value
End With
.Offset(1, 1) = FileItem.Size
.Offset(1, 2) = FileItem.DateCreated
.Offset(1, 3) = FileItem.DateLastModified
End With
'End If
Next FileItem
If InSub Then
For Each SubFolder In .GetFolder(FolderName).SubFolders
ListFilesInFolder SubFolder.Path, True
Next SubFolder
End If
End With
ExitSub:
End Sub
Thanhks vba_gpe nhiều, đã làm được rồi!Bạn sửa lại vầy:
PHP:Private Sub ListFilesInFolder(FolderName As String, InSub As Boolean) Dim FileItem As Object Dim SubFolder As Object Dim FileName As String On Error GoTo ExitSub Set FileItem = CreateObject("Scripting.FileSystemObject") With FileItem For Each FileItem In .GetFolder(FolderName).Files ' If .GetExtensionName(FileItem.Path) = myFile.Path Then With Range("A65536").End(xlUp) With .Offset(1, 0) .Value = FileItem.Path .Parent.Hyperlinks.Add .Cells, .Value End With .Offset(1, 1) = FileItem.Size .Offset(1, 2) = FileItem.DateCreated .Offset(1, 3) = FileItem.DateLastModified End With 'End If Next FileItem If InSub Then For Each SubFolder In .GetFolder(FolderName).SubFolders ListFilesInFolder SubFolder.Path, True Next SubFolder End If End With ExitSub: End Sub