View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Office_Novice Office_Novice is offline
external usenet poster
 
Posts: 245
Default Input the filename into Excel Sheet

Thats a good one try this.

Sub GetEm()
On Error Resume Next
Dim FolderPath 'Path to the folder to be searched for files
Dim objFSO 'The fileSystemObject
Dim objFolder 'The folder object
Dim colFiles 'Collection of files from files method
Dim objFile 'individual file object
Dim ws
Dim x
FolderPath = "E:\" ' Your File Path

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FolderPath)
Set colFiles = objFolder.Files
Set ws = ActiveWorkbook.Worksheets(1)
x = 1
For Each objFile In colFiles
ws.Cells(x, 1).Value = objFile.Name
ws.Cells(x, 2).Value = objFile.Size & " bytes"
x = x + 1
Next
End Sub

"Li Jianyong" wrote:

Dear Experts,

I am asked to input the fillename as text into the Excel sheet. These files
are PDF formated. Like 19347-Autoline-6001004.pdf,it is thousands files. Is
anybody help me to provide me a solution to "read" these file names
automatically into my worksheets like:
A B C
1 19347 Autoline 6001004
2. 19348 autoline 5001045
....

Eager to know the solution!

Li Jianyong