суббота, 6 февраля 2021 г.

How to list mp3 files with details to Excel

How to list mp3 files with details to Excel.
*iPath variable needs for path with music files for scanning.


Sub CreateReport_Mp3FileProperties()
    Dim iFileName$, iPath$, iRow&, iColumn&
    Dim iFolder As Object, iMp3File As Object
        
    iPath = "C:\Users\Office\Desktop\myfolder\": iRow = 2
    
    Set iFolder = CreateObject("Shell.Application").Namespace(CVar(iPath))
    If Not iFolder Is Nothing Then
       iFileName = Dir(iPath & "*.mp3")
       If iFileName <> "" Then
          Workbooks.Add xlWBATWorksheet
          Application.ScreenUpdating = False
          Do
               Application.StatusBar = iFileName
               Set iMp3File = iFolder.ParseName(iFileName)
               For iColumn = 0 To 50 '
                   Cells(iRow, iColumn + 1) = iFolder.GetDetailsOf(iMp3File, iColumn)
               Next
               iFileName = Dir
               iRow = iRow + 1
          Loop While iFileName <> ""
          For iColumn = 0 To 50 ' Headers Report
              Cells(1, iColumn + 1) = iFolder.GetDetailsOf(iFolder.Items, iColumn)
          Next
          Application.StatusBar = False
          Application.ScreenUpdating = True
       Else
          MsgBox "No files .mp3", , ""
       End If
    Else
       MsgBox "Folder doesn't exist", , ""
    End If
End Sub

Комментариев нет:

Отправить комментарий

Постоянные читатели

Популярные сообщения