Excel VBA unable to show the file contents in my folder

I have an issue whereby when I load the file location, it would not show the content of the folder. Example when I run the code, it will show the folder being empty, but it can still load the files into the excel. It is just that the txt files couldn’t be seen. Below is part of the code that will make user select the folder and copy the txt files content to an excel sheet. My only issue is not being able to see the txt files. So, users will not be able to correctly identify if the txt files in the folder is correct or wrong. Is there any way to fix this? The first photo is what it will appear as, the second is the desired result.

      textFileLocation = GetFolderName("C:UsersDocumentsLog")
      
      fileName = Dir(textFileLocation & "*.log") 'first text file  name
      fileDate = Format(FileDateTime(textFileLocation), "mm/dd/yyyy")
      
      If fileName <> "" Then
        Do While fileName <> "" 'loop since there still are not processed text files
            'Get File Name
            sFullFilename = Right(fileName, Len(fileName) - InStrRev(fileName, ""))
            sFileName = Left(sFullFilename, (InStr(sFullFilename, ".") - 1))
            
            'place the content of the text file in an array (split by VbCrLf):
            arrTxt = Split(CreateObject("Scripting.FileSystemObject").OpenTextFile(textFileLocation & "" & fileName, 1).ReadAll, vbCrLf)
            lastR = ws.Range("A" & ws.Rows.Count).End(xlUp).Row 'the row where to paste the array content
    
            'drop the transposed array content:
            ws.Range("A" & IIf(lastR = 1, lastR, lastR + 1)).Resize(UBound(arrTxt) + 1, 1).Value = Application.Transpose(arrTxt)
            
            'apply TextToColumns to whole returned data:
            ws.Columns(1).TextToColumns Destination:=ws.Range("A1"), DataType:=xlFixedWidth, _
            FieldInfo:=Array(Array(0, 1), Array(43, 1), Array(70, 1)), TrailingMinusNumbers:=True

4

Please, try the next adapted code:

Sub ProcessingLogFiles
  Dim textFileLocation As String, fileName As String, ws As Worksheet, lastR As Long
  Dim arrTxt as String, FullPath As String
  
  Set ws = Application.ActiveSheet 'use here the sheet you need
 'adapted to see the files:________________________________________
  With Application.FileDialog(msoFileDialogFilePicker)
        .AllowMultiSelect = False
        .Filters.Add "Log Files", "*.log", 1
        If .Show = -1 Then
             FullPath = .SelectedItems.Item(1) 'selected log file full path
        End If
  End With
  If FullPath = "" Then Exit Sub 'if Cancel pressed, the code stops
  '________________________________________________________________

  textFileLocation = Left(FullPath, InStrRev(FullPath, "") - 1)
  fileName = Dir(textFileLocation & "*.log") 'first log file  name
  
  If fileName <> "" Then
        Do While fileName <> "" 'loop since there still are not processed text files
            'Get File Name
            sFullFilename = Right(fileName, Len(fileName) - InStrRev(fileName, ""))
            sFileName = Left(sFullFilename, (InStr(sFullFilename, ".") - 1))
            
            'place the content of the text file in an array (split by VbCrLf):
            arrTxt = Split(CreateObject("Scripting.FileSystemObject").OpenTextFile(textFileLocation & "" & fileName, 1).ReadAll, vbCrLf)
            lastR = ws.Range("A" & ws.Rows.Count).End(xlUp).Row 'the row where to paste the array content
    
            'drop the transposed array content:
            ws.Range("A" & IIf(lastR = 1, lastR, lastR + 1)).Resize(UBound(arrTxt) + 1, 1).Value = Application.Transpose(arrTxt)
            
            'apply TextToColumns to whole returned data:
            ws.Columns(1).TextToColumns Destination:=ws.Range("A1"), DataType:=xlFixedWidth, _
            FieldInfo:=Array(Array(0, 1), Array(43, 1), Array(70, 1)), TrailingMinusNumbers:=True
'....
'your existing (missing) code
'....
End Sub

You firstly, need to post the whole code. The problem was in the function you used to return the folder to be processed (not supplied). It only happens I knew what you mean from another question I answered it

6

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật