Option Explicit
Sub GetMetaDataFromSoundFiles()
Dim objShellApp As Object
Dim objFolder As Object
Dim varColumns As Variant
Dim arrData() As Variant
Dim wksResults As Worksheet
Dim strPath As String
Dim strFilename As String
Dim fileCount As Long
Dim i As Long
Dim j As Long
strPath = ThisWorkbook.Worksheets("Sheet1").Range("A1").Value
Set objShellApp = CreateObject("Shell.Application")
On Error Resume Next
Set objFolder = objShellApp.Namespace(CStr(strPath))
If objFolder Is Nothing Then
MsgBox "Folder not found!", vbExclamation, "Folder?"
Set objShellApp = Nothing
Exit Sub
End If
On Error GoTo 0
varColumns = Array(166, 13, 21, 243, 16, 14, 247)
ReDim arrData(0 To UBound(varColumns), 0 To objFolder.Items.Count)
For i = LBound(arrData, 1) To UBound(arrData, 1)
arrData(i, 0) = objFolder.GetDetailsOf(objFolder.Items, varColumns(i))
Next i
fileCount = 0
For i = 0 To objFolder.Items.Count - 1
strFilename = objFolder.GetDetailsOf(objFolder.Items.Item(CLng(i)), 0)
If Right(strFilename, 4) = ".mp3" Or Right(strFilename, 4) = ".wav" Then
fileCount = fileCount + 1
For j = 0 To UBound(varColumns)
arrData(j, fileCount) = objFolder.GetDetailsOf(objFolder.Items.Item(CLng(i)), varColumns(j))
Next j
End If
Next i
On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Worksheets(objFolder.Title).Delete
Application.DisplayAlerts = True
On Error GoTo 0
Set wksResults = ThisWorkbook.Worksheets.Add
wksResults.Name = objFolder.Title
wksResults.Range("A1").Resize(UBound(arrData, 2) + 1, UBound(arrData, 1) + 1).Value = Application.Transpose(arrData)
Set objShellApp = Nothing
Set objFolder = Nothing
Set wksResults = Nothing
End Sub