Importing/copying filenames into an excel sheet?


Posted by Garrett on December 22, 2000 8:22 AM

Hi,
Does anybody know how to copy filenames into excel from the Windows NT Explorer?

Here's the problem: I've got one excel spreadsheet with a bunch of image file names in it. I've also got a couple thousand images (jpg's) saved on my harddrive. I want to extract the image names (not the actual picture) from my harddrive, and create a new excel file that I can match up against the existing one (so I can determine which products have no existing image).
Thoughts?

Happy Holidays!
TIA!

Posted by Bruce on December 23, 2000 10:57 AM

Give this macro a try. You might have to customize it.

Sub ListFiles()
Dim myRow As Integer
Dim myFile As String

myRow = 1
myFile = Dir("*.xls")
Do Until myFile = ""
Cells(myRow, 1) = myFile

myRow = myRow + 1
myFile = Dir
Loop
End Sub

Posted by Bruce on December 23, 2000 11:49 AM

myRow = 1 myFile = Dir("*.xls") Do Until myFile = "" Cells(myRow, 1) = myFile myRow = myRow + 1 myFile = Dir Loop

What I meant my customzing is you will need to tell where the directly to look in is.
Example
myFile = Dir("C:\Images\*.jpg") or to get all files in the directory : myFile = Dir("C:\Images\*.*")



Posted by Bruce on December 23, 2000 11:50 AM

myRow = 1 myFile = Dir("*.xls") Do Until myFile = "" Cells(myRow, 1) = myFile myRow = myRow + 1 myFile = Dir Loop

What I meant my customzing is you will need to tell where the directly to look in is.
Example
myFile = Dir("C:\Images\*.jpg") or to get all files in the directory : myFile = Dir("C:\Images\*.*")