Here's what I got.
Code:
sPath = "C:\TEST\"
sPathMember = Dir(sPath, vbDirectory) ' Get the first entry
bracketFound = False
JobNumberHasBeenFound = False
NextDirectoryFound = False
A = 2
c = 1
DirectorySearch:
Do While sPathMember <> "" ' Start the loop
' Be sure to skip over these directory markers
If sPathMember <> "." And sPathMember <> ".." Then
If Right(sPathMember, 1) <> "." And Right(sPathMember, 2) <> ".." Then
'Test if directory
If sPathMember = "" Then
GoTo LeftDown
End If
If (GetAttr(sPath & sPathMember) And vbDirectory) = vbDirectory Then
sPath = sPath & sPathMember & "\"
sPathMember = Dir(sPath, vbDirectory)
End If
End If
End If
MsgBox "Loop 1: " & sPath & sPathMember
sPathMember = Dir
Loop
LeftDown:
If sPathMember = "" Then
' reached end of subdirectories
' go back and down
A = 1
bracketFound = False
Do While bracketFound = False
If Mid(sPath, Len(sPath) - A, 1) = "\" Then
bracketFound = True
sPath = Left(sPath, Len(sPath) - A)
End If
If bracketFound = False Then A = A + 1
Loop
A = 2
sPathMember = Dir(sPath, vbDirectory)
Do While sPathMember <> ""
If sPathMember <> "." And sPathMember <> ".." Then
If Right(sPathMember, 1) <> "." And Right(sPathMember, 2) <> ".." Then
If (GetAttr(sPath & sPathMember) And vbDirectory) = vbDirectory Then
NewPath = sPath & sPathMember
If currentPath = NewPath Then GoTo NotThisFolder
MsgBox "Current: " & currentPath & " New: " & NewPath
currentPath = sPath & sPathMember
GoTo DirectorySearch:
End If
End If
End If
NotThisFolder:
sPathMember = Dir
Loop
MovedDown:
End If
ExitFolderSearch:
almost seemed to work at first but can't seem to find any clear examples of how to do this on the net.
It's just supposed to do a folder search through all the folders on the hard drive, searching for a folder name that contains the job name. Spent the day troubleshooting it and seem to be getting nowhere. Any ideas? thanks