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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sub Folders

Status
Not open for further replies.

sanders720

Programmer
Aug 2, 2001
421
US
I am using the "file system object model" feature to obtain information about folders.

I have several hundred jobs, ie: 36401, 36402, 36403, etc. I have a routine that looks for files under all the directories and places the hyperlink location in a field for a particular record. I would like the routine to just search for a subfolder called '\parts' under the job number. The folder could be anywhere in the sub folder heiarchy.

In other words, 36401 looks to \36401\mechanical\parts,
36402 looks to \36402\mechanical\rev_a\parts, and
36403 looks to \36403\electrical\500A\parts, etc. Hopefully you see what I mean here.

Currently my program looks in all sub folders, which takes LOTS OF TIME! To reiterate, I just need it to find the PARTS folder under each job and modift the data that way.

My current code looks something like this...The 'f' variable becomes a string of folders in a loop.

Thanks in advance for the help...

Private Function LookAtFiles(ByVal folderspec As String, ByVal filename As String) As String
Dim fs, f, f1, fc, s

Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FolderExists(folderspec) Then
Set f = fs.GetFolder(folderspec)
Debug.Print f
Set fc = f.Files

LookAtFiles = ""

For Each f1 In fc
If CancelSearch = True Then
cmdCopyFiles.Caption = "Copy Files for Manual"
Exit Function
End If

If LCase(f1.Name) = LCase(filename) Then
If Right(folderspec, 1) = "\" Then
LookAtFiles = folderspec & filename
Else
LookAtFiles = folderspec & "\" & filename
End If
Exit Function
End If
Next
End IfEnd Function



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top