Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want fo get in a worksheet a list of all files in a particular directory.
For each file in the folder I want to get: name, size and date. Thanks. -- gilgil259 Antispam: replace 259 with 159 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Gilgil,
Try the following which was previously posted by Jim Thomlinson:: '============= Sub ListFiles() Dim fso As New FileSystemObject Dim oCurrentFile As File Dim oCurrentFolder As Folder Dim wks As Worksheet Dim rng As Range Set wks = Sheets("Sheet1") Set rng = wks.Range("A2") Set oCurrentFolder = fso.GetFolder("C:\Windows") For Each oCurrentFile In oCurrentFolder.Files rng.Value = oCurrentFile.Name rng.Offset(0, 1).Value = oCurrentFile.ShortName rng.Offset(0, 2).Value = oCurrentFile.Path rng.Offset(0, 3).Value = oCurrentFile.DateCreated rng.Offset(0, 4).Value = oCurrentFile.DateLastAccessed rng.Offset(0, 5).Value = oCurrentFile.DateLastModified rng.Offset(0, 6).Value = oCurrentFile.Size rng.Offset(0, 7).Value = oCurrentFile.Type rng.Offset(0, 8).Value = oCurrentFile.Attributes Set rng = rng.Offset(1, 0) Next oCurrentFile End Sub '<<============= --- Regards, Norman "gilgil" wrote in message ... I want fo get in a worksheet a list of all files in a particular directory. For each file in the folder I want to get: name, size and date. Thanks. -- gilgil259 Antispam: replace 259 with 159 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Gilgil,
Just to add, to use this code you will need to add a reference in the VBE to the Microsft Scripting Runtime library. In the VBE: Tools | References | Check 'Microsoft Scripting Runtime' --- Regards, Norman "Norman Jones" wrote in message ... Hi Gilgil, Try the following which was previously posted by Jim Thomlinson:: '============= Sub ListFiles() Dim fso As New FileSystemObject Dim oCurrentFile As File Dim oCurrentFolder As Folder Dim wks As Worksheet Dim rng As Range Set wks = Sheets("Sheet1") Set rng = wks.Range("A2") Set oCurrentFolder = fso.GetFolder("C:\Windows") For Each oCurrentFile In oCurrentFolder.Files rng.Value = oCurrentFile.Name rng.Offset(0, 1).Value = oCurrentFile.ShortName rng.Offset(0, 2).Value = oCurrentFile.Path rng.Offset(0, 3).Value = oCurrentFile.DateCreated rng.Offset(0, 4).Value = oCurrentFile.DateLastAccessed rng.Offset(0, 5).Value = oCurrentFile.DateLastModified rng.Offset(0, 6).Value = oCurrentFile.Size rng.Offset(0, 7).Value = oCurrentFile.Type rng.Offset(0, 8).Value = oCurrentFile.Attributes Set rng = rng.Offset(1, 0) Next oCurrentFile End Sub '<<============= --- Regards, Norman |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you very much. That is really what I am looking for.
-- gilgil259 Antispam: replace 259 with 159 "Norman Jones" ha scritto nel messaggio ... Hi Gilgil, Try the following which was previously posted by Jim Thomlinson:: '============= Sub ListFiles() |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Creating a list using the file names | Excel Discussion (Misc queries) | |||
how do I import a list of music file names into excel | Excel Discussion (Misc queries) | |||
How to create a list of file names within a folder in Microsoft Ex | Excel Discussion (Misc queries) | |||
how can you list all of the worksheet names in a file | Excel Discussion (Misc queries) | |||
need to copy a long list of file names | Excel Discussion (Misc queries) |