Attribute VB_Name = "TeamsCacheListFiles"
Option Explicit

Public Sub TeamsCacheListFiles()
    Dim fso As Object
    Dim folder As Object
    Dim f As Object
    Dim folderPath As String
    Dim ws As Worksheet
    Dim r As Long

    folderPath = Environ("APPDATA") & "\Microsoft\Teams\Cache"

    Set fso = CreateObject("Scripting.FileSystemObject")

    If Not fso.FolderExists(folderPath) Then
        MsgBox "Folder not found:" & vbCrLf & folderPath, vbExclamation
        Exit Sub
    End If

    Set ws = ActiveSheet
    ws.Cells.Clear
    ws.Cells(1, 1).Value = "File Name"
    ws.Cells(1, 2).Value = "Size (KB)"
    ws.Cells(1, 3).Value = "Last Modified"
    ws.Rows(1).Font.Bold = True

    Set folder = fso.GetFolder(folderPath)
    r = 2
    For Each f In folder.Files
        ws.Cells(r, 1).Value = f.Name
        ws.Cells(r, 2).Value = Format(f.Size / 1024, "#,##0.0")
        ws.Cells(r, 3).Value = f.DateLastModified
        r = r + 1
    Next f

    ws.Columns.AutoFit
    MsgBox (r - 2) & " file(s) listed from " & folderPath, vbInformation
End Sub