M
myles_everblue via AccessMonster.com
Does anyone know how can i search files and folders? I have this code but it
only searches for a file and not a folder.
With Application.FileSearch
.NewSearch
.LookIn = gPathName
.SearchSubFolders = True
.FileName = strCode
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
If .Execute > 0 Then
MsgBox "There were" & .FoundFiles.Count & _
"file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
IntRes = MsgBox("There were No Folder found." & _
"Do you want to Create folder?", vbYesNo + vbQuestion)
If IntRes = vbNo Then
Exit Sub
Else
MkDir gPathName & strCode
MsgBox "Folder" & strCode & "has been created", vbOKOnly +
vbInformation
End If
End If
End With
only searches for a file and not a folder.
With Application.FileSearch
.NewSearch
.LookIn = gPathName
.SearchSubFolders = True
.FileName = strCode
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
If .Execute > 0 Then
MsgBox "There were" & .FoundFiles.Count & _
"file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
IntRes = MsgBox("There were No Folder found." & _
"Do you want to Create folder?", vbYesNo + vbQuestion)
If IntRes = vbNo Then
Exit Sub
Else
MkDir gPathName & strCode
MsgBox "Folder" & strCode & "has been created", vbOKOnly +
vbInformation
End If
End If
End With