Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Revisiting Some Excellent MP3 Code (XL 2003)

    I have used the code shown below many times since Andrew Cronnolly <!post=posted,265254>posted<!/post> it several years ago... Now, I'd like to make a change to the code. Rather than "hard-wiring" a directory for the code to search, is there a way to make the code ask for a directory to search? As it is, the code when ran, will return a list of 12,000 tracks and sometimes that's useful! However, I may just want to return a list of the Beatles tracks, etc. I'd like to be prompted for a starting point... Any takers?



    <pre>Public Type mp3Info
    Header As String * 3
    Title As String * 30
    Artist As String * 30
    Album As String * 30
    Year As String * 4
    Comment As String * 30
    Genre As Byte
    End Type

    Sub FindMP3Info()
    Application.ScreenUpdating = False
    Dim oFSearch As FileSearch
    Dim varFile As Variant
    Dim mp3ID As mp3Info
    Set oFSearch = Application.FileSearch
    With oFSearch
    .NewSearch
    .LookIn = "Cocuments and SettingsRickyMy DocumentsMy Music"
    .Filename = "*.mp3"
    .SearchSubFolders = True
    If .Execute() > 0 Then
    For Each varFile In .FoundFiles
    lngFile = FreeFile
    Open varFile For Binary As lngFile
    Get lngFile, LOF(1) - 127, mp3ID
    Close lngFile
    If mp3ID.Header = "TAG" Then
    ActiveCell.Offset(lngRow, 0) = varFile ' or fi.Name
    With mp3ID
    ActiveCell.Offset(lngRow, 1) = .Title
    ActiveCell.Offset(lngRow, 2) = .Artist
    ActiveCell.Offset(lngRow, 3) = .Album
    ActiveCell.Offset(lngRow, 4) = .Year
    ActiveCell.Offset(lngRow, 5) = .Genre
    ActiveCell.Offset(lngRow, 6) = .Comment
    End With
    lngRow = lngRow + 1
    End If
    Next
    End If
    End With
    Application.ScreenUpdating = True
    End Sub</pre>

    - Ricky

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Revisiting Some Excellent MP3 Code (XL 2003)

    You can use code like this:

    Dim strFolder As String
    With Application.FileDialog(msoFileDialogFolderPicker)
    ' Specify a folder to start in - use C: if you want to see the entire HD
    .InitialFileName = "Cocuments and SettingsRicky"
    If .Show = True Then
    strFolder = .SelectedItems(1)
    Else
    MsgBox "No folder selected!", vbExclamation
    Exit Sub
    End If
    End With

    and change the line

    .LookIn = "Cocuments and SettingsRickyMy DocumentsMy Music"

    to

    .LookIn = strFolder

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Revisiting Some Excellent MP3 Code (XL 2003)

    Would I place this in the same module as the existing code?

    Dim strFolder As String
    <pre>With Application.FileDialog(msoFileDialogFolderPicker)
    ' Specify a folder to start in - use C: if you want to see the entire HD
    .InitialFileName = "Cocuments and SettingsRicky"
    If .Show = True Then
    strFolder = .SelectedItems(1)
    Else
    MsgBox "No folder selected!", vbExclamation
    Exit Sub
    End If
    End With</pre>

    - Ricky

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Revisiting Some Excellent MP3 Code (XL 2003)

    <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30> - Never mind... I just figured it out where the code goes. Already tried it out and it does just what I wanted it to. As always, Thanks

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    - Ricky

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Revisiting Some Excellent MP3 Code (XL 2003)

    Insert the code fragment into the macro, Ricky, immediately above the line

    Set oFSearch = ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •