Thread
:
Dir function resetting
View Single Post
#
2
Posted to microsoft.public.excel.programming
Don Guillett[_4_]
external usenet poster
Posts: 2,337
Dir function resetting
try to modify this idea to suit
Sub anotherfindfiles()
Application.ScreenUpdating = False
Dim FN As String ' For File Name
Dim ThisRow As Long
Dim MediaFileLocation As String
MediaFileLocation = "c:\yourfolder\*.mp3"
FN = Dir(MediaFileLocation)
Do Until FN = ""
ThisRow = ThisRow + 1
Cells(ThisRow, 1) = FN
FN = Dir
Loop
Application.ScreenUpdating = True
End Sub
--
Don Guillett
SalesAid Software
"Emily Edgington" wrote in
message ...
I am trying to use the Dir function to loop through folders in specified
directories, and again to loop through the files in those folders, but my
second Dir is messing with the first one ("RecFile = Dir" in inner loop
makes
"Folder=Dir" in outer loop no longer work).
I have tried putting the inner loop in it's own procedure and calling it
within the outer loop, to no avail. Any suggestions?
Dim FolderPath As String
Dim Folder As String
Dim RecFile As String
Public Sub Create_File_List()
Folder = Dir(FolderPath, vbDirectory)
Do While Folder < ""
If Folder < "." And Folder < ".." Then
If (GetAttr(FolderPath & Folder) And vbDirectory) = vbDirectory
Then
RecFile = Dir(FolderPath & Folder & "\*-pt.xls")
Do Until RecFile = ""
'insert some formulas, yadda yadda yadda
RecFile = Dir
Loop
End If
End If
Folder = Dir
Loop
End Sub
Reply With Quote
Don Guillett[_4_]
View Public Profile
Find all posts by Don Guillett[_4_]