![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: Pittsburgh, PA
Posts: 317
|
Does anyone have any code that I could have that would enable me to retrieve all of the filename and their locations of the directory and sub-directories. I know there is a way to do it, but I am under a tight schedule [tomorrow!] and need it done right away.
Please help!
__________________
Thanks in advance, Patrick |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Redmond, WA
Posts: 636
|
Goto dos and type the following command.
dir/s > files.txt |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: Pittsburgh, PA
Posts: 317
|
how do i get to DOS on windows 2000?
__________________
Thanks in advance, Patrick |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
|
goto run
type cmd |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Apr 2002
Location: Pittsburgh, PA
Posts: 317
|
I did it using the following:
Sub GetFilenames() Set fs = Application.FileSearch With fs .LookIn = "X:Line Balancing Project - Maynard" .SearchSubFolders = True .Filename = "*" If .Execute(SortBy:=msoSortByFileName, _ SortOrder:=msoSortOrderAscending) > 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." For i = 1 To .FoundFiles.Count ActiveCell.Value = .FoundFiles(i) ActiveCell.Offset(1, 0).Select Next i Else MsgBox "There were no files found." End If End With End Sub |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Apr 2002
Location: Redmond, WA
Posts: 636
|
Using dir/s > files.txt is a lot easier
|
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Apr 2002
Location: Pittsburgh, PA
Posts: 317
|
I see. I have never used DOS before. I had no idea. Thanks for the info.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|