Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel file list (dir) 2

Status
Not open for further replies.

faxof

Programmer
Dec 5, 2001
272
0
0
GB
I need to use excel to pull a list of all the files held in a network folder, m:\apps\usage\ad
i need to pull out a list of all the files in that directory and their modified date

any ideas?
faxof
 
faxof,

Try this code in VBA:

-----------------------------
Dim m_FSObject
Dim m_Folder
Dim m_File
Dim m_Files
Dim iCnt

Set m_FSObject = CreateObject("Scripting.FileSystemObject")

Set m_Folder = m_FSObject.GetFolder("m:\apps\usage\ad")
Set m_Files = m_Folder.Files

For Each m_File In m_Files
iCnt = iCnt + 1

With ThisWorkbook
.Application.Cells(iCnt, 1) = m_File.Name
End With

Next
------------------------------------------------------

Hope this helps,
~Kevin
 
Kevin
That's good - but it only seems to pull out the file names - how can i get the Last Modified data also?


faxof
 
faxof,

just add the following line of code under the .Application.Cells(iCnt,1) = m_File.Name line:

.Application.Cells(iCnt, 2) = m_File.DateLastModified

This will put the last modified date in column B for each file in column A.

~Kevin
 
faxof,

I just want to make sure my last post answered your question. I don't want to leave you hanging. If it didn't answer your question please let me know.

Thanks
 
It worked liek a treat.
thanx

faxof
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top