VBA to read MP3 metadata is not pulling in information

WarrenCarr

New Member
Joined
Apr 4, 2017
Messages
23
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I have a VBA macro that i want to run. It is supposed to pull MP3 + Wav meta data into excel. When I run it, it seems to work but doesnt actually pull in any data. Can anyone suggest what might be wrong? I am very inexperienced with VBA.

Thanks,
WC
 

Attachments

  • 2023-05-19 11_12_10-Tokyo Music Walker - Clover.png
    2023-05-19 11_12_10-Tokyo Music Walker - Clover.png
    11 KB · Views: 11
  • 2023-05-20 03_10_31-Microsoft Visual Basic for Applications - Cozy Cafe Music - MP3 Import.xls...png
    2023-05-20 03_10_31-Microsoft Visual Basic for Applications - Cozy Cafe Music - MP3 Import.xls...png
    47 KB · Views: 11

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
The metadata (numbers) could be different on other operating systems
This macro prints the numbers and their meaning on your system.

VBA Code:
Sub jec()
 With CreateObject("shell.application").Namespace("C:\Users\xxx\Music\")     'change path
    For i = 0 To 40
       Debug.Print i & " = " & .getdetailsof(Null, i)
    Next
 End With
End Sub
 
Upvote 0
Once you have the correct numbers, you can use it like

VBA Code:
Sub jecc()
 Dim x00, sp, sq, ar, j As Long, i As Long
 x00 = "C:\Users\xxx\Music\*.mp3"
 sp = Split(CreateObject("wscript.shell").exec("cmd /c Dir """ & x00 & """ /b/o:n").stdout.readall, vbCrLf)
 sq = Array(0, 15, 16, 27, 20, 1, 3, 2, 28)   'These numbers should be in line with the array in the second-last line.
 
 ReDim ar(UBound(sp), UBound(sq))
 For i = 0 To UBound(sp) - 1
    With CreateObject("shell.application").Namespace(CStr(Split(x00, "*")(0)))
      For j = 0 To UBound(sq)
        ar(i, j) = .getdetailsof(.Items.Item(CStr(sp(i))), sq(j))
      Next
    End With
 Next
      
 Cells(1, 1).Resize(, UBound(ar, 2) + 1) = Array("Name", "Year", "Genre", "Time", "Albumartist", "Size", "Changed on", "Type", "Bitrate")
 Cells(2, 1).Resize(UBound(sp), UBound(ar, 2) + 1) = ar
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,148
Messages
6,123,301
Members
449,095
Latest member
Chestertim

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top