Importing text from an Explorer window

D

Don

Howdy all.

OS: XP, Excel 2002 SP3

I have my music stored in the My Music directory. I have Artist, Album
Title, etc. attributes turned on. What I'd like to do is to take all of this
information and input it into an Excel spreadsheet. When I "Select All" from
the window, and "Copy", it wants to copy the actual songs, and not the text.
Also, the "Paste" option in Excel is grayed out anyway.

Is there a way that I can treat the info in a Browser window as just text,
and then copy that info into a spreadsheet?

TIA.
 
D

Don Guillett

Here is one I have used in my "songs.xls". Written a couple of years ago.

Sub FindFiles()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
'sets Erase or Append option
lastrow = Range("a65536").End(xlUp).Row
If lastrow = 4 Then lastrow = 5 Else lastrow = lastrow
'MsgBox lastrow
If UCase([a3]) = "E" Then
Range("a5:f" & lastrow).ClearContents
lastrow = 4
ElseIf UCase([a3]) = "A" Then lastrow = lastrow
End If
'Sets Musicpath
If Right([a1], 1) <> "\" And Left([a1], 1) <> "_" Then x = "\"
If IsEmpty([a2]) = False And Right([a2], 1) <> "\" Then y = "\"
musicpath = [a1] & x & [a2] & y
'Finds Files
With Application.FileSearch
.NewSearch
.LookIn = musicpath
.SearchSubFolders = True 'False
.MatchTextExactly = False
.Filename = ".mp3" '*.mp3* did not work in 97
If .Execute(msoSortOrderDescending) > 0 Then
'MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
'MsgBox Mid(.FoundFiles(i), Len(musicpath) + 1, 2)
If Mid(.FoundFiles(i), Len(musicpath) + 1, 2) <> "__" Then 'added for
__INCOMPLETE

x = Application.Find("\", StrReverse(.FoundFiles(i))) - 2 'must have
function before xl2000
y = Application.Find("-", StrReverse(.FoundFiles(i))) - 1

Cells(i + lastrow, 1).Value = Mid(.FoundFiles(i), Len(.FoundFiles(i)) - x,
x - y)
x = Application.Find("-", .FoundFiles(i)) + 1
Cells(i + lastrow, 2).Value = Mid(.FoundFiles(i), x, Len(.FoundFiles(i)) -
x - 3)
Cells(i + lastrow, 3).Value = FileLen(.FoundFiles(i))
Cells(i + lastrow, 4).Value = FileDateTime(.FoundFiles(i))
Cells(i + lastrow, 5).Value = .FoundFiles(i) 'Path to play
End If 'added
Next i

Else
MsgBox "There were no files found."
End If
End With

Range("a5:g" & Range("a65536").End(xlUp).Row) _
..Sort Key1:=Cells(1, 1), Order1:=xlAscending, Key2:=Cells(1, 2),
Order2:=xlAscending, Orientation:=xlTopToBottom
[a5].Select
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
 
D

Don

Dumb question: How do I run a script like this on a PC?

Thanks for the reply.

Don

--
Don Cox
Don Guillett said:
Here is one I have used in my "songs.xls". Written a couple of years ago.

Sub FindFiles()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
'sets Erase or Append option
lastrow = Range("a65536").End(xlUp).Row
If lastrow = 4 Then lastrow = 5 Else lastrow = lastrow
'MsgBox lastrow
If UCase([a3]) = "E" Then
Range("a5:f" & lastrow).ClearContents
lastrow = 4
ElseIf UCase([a3]) = "A" Then lastrow = lastrow
End If
'Sets Musicpath
If Right([a1], 1) <> "\" And Left([a1], 1) <> "_" Then x = "\"
If IsEmpty([a2]) = False And Right([a2], 1) <> "\" Then y = "\"
musicpath = [a1] & x & [a2] & y
'Finds Files
With Application.FileSearch
.NewSearch
.LookIn = musicpath
.SearchSubFolders = True 'False
.MatchTextExactly = False
.Filename = ".mp3" '*.mp3* did not work in 97
If .Execute(msoSortOrderDescending) > 0 Then
'MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
'MsgBox Mid(.FoundFiles(i), Len(musicpath) + 1, 2)
If Mid(.FoundFiles(i), Len(musicpath) + 1, 2) <> "__" Then 'added for
__INCOMPLETE

x = Application.Find("\", StrReverse(.FoundFiles(i))) - 2 'must have
function before xl2000
y = Application.Find("-", StrReverse(.FoundFiles(i))) - 1

Cells(i + lastrow, 1).Value = Mid(.FoundFiles(i), Len(.FoundFiles(i)) - x,
x - y)
x = Application.Find("-", .FoundFiles(i)) + 1
Cells(i + lastrow, 2).Value = Mid(.FoundFiles(i), x, Len(.FoundFiles(i)) -
x - 3)
Cells(i + lastrow, 3).Value = FileLen(.FoundFiles(i))
Cells(i + lastrow, 4).Value = FileDateTime(.FoundFiles(i))
Cells(i + lastrow, 5).Value = .FoundFiles(i) 'Path to play
End If 'added
Next i

Else
MsgBox "There were no files found."
End If
End With

Range("a5:g" & Range("a65536").End(xlUp).Row) _
.Sort Key1:=Cells(1, 1), Order1:=xlAscending, Key2:=Cells(1, 2),
Order2:=xlAscending, Orientation:=xlTopToBottom
[a5].Select
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top