About a year ago I posted a pair of macros to read/write MP3 tags. The Read macro puts file data into a worksheet for making changes, the Write macro uses the worksheet to change the files.The problem with the Write macro was that, although it did work, it used SendKeys which has to be slowed down considerably.
Here is a new version of the Write macro that works as normal. I originally tried to use CDDBControl.dll version 1.2.0.51 which is widely available on the internet but found that I could only get it to change 1 file before crashing Excel. There is a later version 2.0.0.6 but I could not find a download. You might have better success. In "fuzzy" searching for a replacement I found CDDBControlRoxio.dll on my own computer ( I own some of their software) which seems to function the same - except that it actually works. If you have problems with the .dll there seem to be several around with similar names that could be tried. The .dll needs to be registered on your computer by running regsvr32 followed by its file name.
I have put the READ macro in the next message.
Here is a new version of the Write macro that works as normal. I originally tried to use CDDBControl.dll version 1.2.0.51 which is widely available on the internet but found that I could only get it to change 1 file before crashing Excel. There is a later version 2.0.0.6 but I could not find a download. You might have better success. In "fuzzy" searching for a replacement I found CDDBControlRoxio.dll on my own computer ( I own some of their software) which seems to function the same - except that it actually works. If you have problems with the .dll there seem to be several around with similar names that could be tried. The .dll needs to be registered on your computer by running regsvr32 followed by its file name.
I have put the READ macro in the next message.
Code:
'==========================================================================================================
'- MACRO TO CHANGE EXTENDED FILE PROPERTIES OF .MP3 AND .WMA FILES IN WINDOWS EXPLORER
'- Reads from amended worksheet prepared with separate "READ_FROM_EXPLORER" macro module.
'==========================================================================================================
'- .WMA files do not have track number column 4
'- this version uses CDDBControlRoxio.dll
'- (was unable to get CDDBControl.dll version 1.2.0.51 to change more than 1 file without crashing)
'- Suggest you copy some files to a special folder for testing first.
'- Brian Baulsom May 2008 - using Excel 2000/Windows XP
'==========================================================================================================
'==========================================================================================================
'- Method (works on all files in a single folder)
'- 1. Run macro "READ_FROM_EXPLORER" (other module) TO GET FILE NAMES INTO CURRENTLY ACTIVE WORKSHEET
'- 2. Amend file details in the worksheet. Delete rows for files not changed to save time (can be left).
'- 3. Run macro "WRITE_TO_EXPLORER" below.
'==========================================================================================================
'- also uses Public variables in READ macro module
Dim ws As Worksheet
Dim FromRow As Long
Dim LastRow As Long
Dim FilesToChange As Integer ' number of files to change
Dim FilesChanged As Integer ' number of files changed
Dim MyFilePathName As String ' full path & file name
Dim MyFileType As String ' mp3 wma etc.
'-
Dim id3 As Object
Dim MyArtist As String
Dim MyAlbum As String
Dim MyGenre As String
Dim MyTrack As String
Dim MyTitle As String
'==========================================================================================================
'- MAIN ROUTINE
'- Run down visible rows and change data
'- worksheet has full path & file name in column O
'==========================================================================================================
Sub WRITE_TO_EXPLORER()
Application.Calculation = xlCalculationManual
Set ws = ActiveSheet
Set id3 = CreateObject("CDDBControlRoxio.CddbID3Tag")
'-----------------------------------------------------------------------------------------------------
'- CHECK NUMBER OF FILES TO CHANGE (VISIBLE ROWS)
LastRow = ws.Range("A65536").End(xlUp).Row ' count worksheet rows
FilesToChange = ws.Range("A2:A" & LastRow).SpecialCells(xlCellTypeVisible).Count
If FilesToChange = 0 Then MsgBox ("No files to change."): Exit Sub
FilesChanged = 0
'-----------------------------------------------------------------------------------------------------
'- LOOP WORKSHEET FILES - VISIBLE ROWS ONLY
For FromRow = 2 To LastRow
If ws.Cells(FromRow, "A").EntireRow.Hidden = False Then
'---------------------------------------------------------------------------------------------
'- Get file properties from sheet
With ws
MyFilePathName = .Cells(FromRow, "O").Value
MyFileType = UCase(Right(MyFilePathName, 3))
Application.StatusBar = FileCount & "\" & FilesToChange & " " & MyFilePathName 'STATUSBAR
MyArtist = .Cells(FromRow, "B").Value
MyAlbum = .Cells(FromRow, "C").Value
MyTrack = .Cells(FromRow, "E").Value
MyGenre = .Cells(FromRow, "F").Value
MyTitle = .Cells(FromRow, "H").Value
End With
'---------------------------------------------------------------------------------------------
'- Write to file
With id3
.LoadFromFile MyFilePathName, False ' True = Read Only
.LeadArtist = MyArtist
.Album = MyAlbum
.Genre = MyGenre
.Title = MyTitle
If MyFileType = "MP3" Then .TrackPosition = MyTrack
.SaveToFile MyFilePathName
End With
'---------------------------------------------------------------------------------------------
FilesChanged = FilesChanged + 1
End If
Next
'-----------------------------------------------------------------------------------------------------
'- end of program
Application.Calculation = xlCalculationAutomatic
rsp = MsgBox("Done" & vbCr & "Changed " & FilesChanged & " of " & FilesToChange)
Application.StatusBar = False
End Sub
'======= END OF MAIN ======================================================================================