PDA

View Full Version : Solved: Edit MP3 tags in Excel / VBA



MrTinkertrai
05-21-2008, 12:23 PM
Hello all,

I've been busy trying to figure out how to edit MP3 tags in Excel/VBA.
I've found a method which makes use of a DLL-file called cddbcontrol.dll.
Here's the code which is working for me :
Code:
Sub MP3TagChange()
Sheets("MP3tags").Select
Dim id3 As New CddbID3Tag
id3.LoadFromFile Range("A2").Value, False
id3.Album = Range("B2").Value
id3.Title = Range("E2").Value
id3.LeadArtist = Range("F2").Value
id3.Year = Range("G2").Value
id3.Genre = Range("H2").Value
id3.TrackPosition = Range("I2").Value
id3.SaveToFile Range("A2").Value
End Sub


In A2 I have the full path to a MP3-file.
This code is working and the changes are being made to that file.[/vba]
What I'd like to do is to change this code, so that it changes the tags for all the Mp3's which are listed in Col A.
I hope someone can help me out on this one..

Thanks in advance,
Mike

Bob Phillips
05-21-2008, 01:50 PM
Public Sub ProcessCells()
Dim id3 As New CddbID3Tag
Dim LastRow As Long
Dim i As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow

MP3TagChange id3, .Cells(i, "A")
Next i
End With

End Sub

Private Sub MP3TagChange(ByRef id3 As CddbID3Tag, ByRef cell As Range)
With cell
id3.LoadFromFile .Value, False
id3.Album = .Offset(0, 1).Value
id3.Title = .Offset(0, 4).Value
id3.LeadArtist = .Offset(0, 5).Value
id3.Year = .Offset(0, 6).Value
id3.Genre = .Offset(0, 7).Value
id3.TrackPosition = .Offset(0, 8).Value
id3.SaveToFile .Value
End With
End Sub

MrTinkertrai
05-21-2008, 09:15 PM
Many thanx, xld
I'm gonna give this one a try :)