sanders720
Programmer
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"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
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
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