Exporting file names to an excel spreadsheet.

  • Thread starter Thread starter Kepf
  • Start date Start date
K

Kepf

I have a folder containing many many many .pdf files.

Is there a way to export the filenames of these .pdf files into an
excel spreadsheet?

If this is a dumb question, I apologize. I didnt have any luck
searching for the answer here.
 
modify to suit

Sub FindExcelFiles()
Application.ScreenUpdating = False
Dim FN As String ' For File Name
Dim ThisRow As Long
Dim FileLocation As String
FileLocation = "c:\yourfoldername\*.pdf'.xls"
FN = Dir(FileLocation)
Do Until FN = ""
ThisRow = ThisRow + 1
Cells(ThisRow, 1) = FN
FN = Dir
Loop
Application.ScreenUpdating = True
End Sub
 
Don -

If the items in the target folder are a mixed bag of files and folders, is
there a way to determine if an item found by Dir() is a folder or a file?

Ed
 
try to modify this idea to suit
Sub findonefile()
With Application.FileSearch
.NewSearch
.LookIn = "C:\yourmainfolder"
.SearchSubFolders = true'seach sub folders too
'.Filename = "MyFile.txt"
.Filename = "ReadMe.txt"
'.MatchTextExactly = True
'.FileType = msoFileTypeAllFiles
iexecuteresult = .Execute()

End With
MsgBox iexecuteresult
End Sub
 
Thank you!!
Ed

Don Guillett said:
try to modify this idea to suit
Sub findonefile()
With Application.FileSearch
.NewSearch
.LookIn = "C:\yourmainfolder"
.SearchSubFolders = true'seach sub folders too
'.Filename = "MyFile.txt"
.Filename = "ReadMe.txt"
'.MatchTextExactly = True
'.FileType = msoFileTypeAllFiles
iexecuteresult = .Execute()

End With
MsgBox iexecuteresult
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

Back
Top