• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

PDF Names to Excel

vidyadhar

New Member
Hi Experts,

I have a folder with around 200 to 250 PDF files, I just need all the file names only to be copied into Excel with a VBA code.

Thank you in Advance
 
Vidyadhar

Firstly, Welcome to the Chandoo.org Forums

I would do the following:

Click on the Windows Start menu and in the Search Programs and Files dialog, type CMD
In the DOS window that opens change directory to where your files are stored
eg: if the file is on D:\Files\Mypdfs use
D:
cd \Files\Mypdfs

Use a command like Dir *.pdf /B > mypdfs.txt
That will make a new file called mypdfs.txt which will have a list of the PDF's
You can now open that file and copy the list to use as you want
 
If you want to do it all within XL instead of DOS, here's the code snippet
Code:
Sub ListFiles()
Dim myFolder As String
Dim myFile As String
Dim i As Integer
 
'Be sure to include a slash mark at end of file path
myFolder = "C:\My Documents\"
 
'start output in row 1
i = 1
 
'looking for pdfs
myFile = Dir(myFolder & "*.pdf")
 
Application.ScreenUpdating = False
Do Until myFile = ""
    Cells(i, "A").Value = myFile
    i = i + 1
    myFile = Dir()
Loop
Application.ScreenUpdating = True
    
End Sub
 
Back
Top