Lỗi code trong file excel

Liên hệ QC
- File đính kèm bị lỗi như thế nào xin các AC chỉ giáo!
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
 
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
Thanhks vba_gpe nhiều, đã làm được rồi!
 
Web KT

Bài viết mới nhất

Back
Top Bottom