PC Review


Reply
Thread Tools Rate Thread

How do I display all the filename in a folder in excel ?

 
 
Eng Teng
Guest
Posts: n/a
 
      7th Jun 2008
How do I display all the filename in a folder in excel ?
Example : In c:\abc folder got filename file1.txt , file2.txt and file3.txt

How do I display in excel in the following order :-
c:\abc\file1.txt
c:\abc\file2.txt
c:\abc\file3.txt

Regards,
Tee



 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      7th Jun 2008

Sub ListAllFilesInFolder()
'Jim Cone - Portland Oregon - USA
Dim strPath As String
Dim oFSO As Object
Dim oFile As Object
Dim oFolder As Object
Dim N As Long

strPath = "C:\Program Files\Microsoft Office\Office11"

N = 1
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(strPath)
Cells(N, 1).Value = oFolder.Path
N = N + 1
For Each oFile In oFolder.Files
Cells(N, 2).Value = oFile.Name
N = N + 1
Next 'oFile
Set oFSO = Nothing
Set oFile = Nothing
Set oFolder = Nothing
End Sub
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins - free trial of "List Files" - no registration)




"Eng Teng"
wrote in message
How do I display all the filename in a folder in excel ?
Example : In c:\abc folder got filename file1.txt , file2.txt and file3.txt
How do I display in excel in the following order :-
c:\abc\file1.txt
c:\abc\file2.txt
c:\abc\file3.txt
Regards,
Tee
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filename display wallymeister Microsoft Access 2 10th Feb 2010 07:13 PM
Display Filename RICHARD BROMBERG Microsoft Frontpage 1 29th Jun 2007 03:27 PM
FileName display gopal Microsoft C# .NET 3 12th Sep 2006 09:50 PM
set excel <filename> to <filename-date> bob engler Microsoft Excel Programming 2 12th Jul 2006 08:22 AM
To display contents of a folder in an excel sheet using Excel MACRO vishucool@gmail.com Microsoft Excel Worksheet Functions 1 24th Jun 2006 01:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:06 AM.