When using application.FileSearch, file not found

P

PCC Ken

The code is below.

On most PCs at our work, it works without a problem. However on some PCs it
finds the network file just fine, but can't find the file on C: drive.

Ken


Dim F 'Script variable
Set F = CreateObject("Scripting.FileSystemObject")
Set fs = application.FileSearch
With fs 'Search Client and get current filename for ToolingServices.mde
.LookIn = PCAppPath 'Default directory created from setup.exe
.SearchSubFolders = False
.Filename = "ToolingServices*.mde"
If .Execute() > 0 Then
'MsgBox "There were " & .FoundFiles.Count & _
'" file(s) found."
For i = 1 To .FoundFiles.Count
Name1 = F.GetFileName(.FoundFiles(i)) 'Used for Client filename
search(see Module)
'X = MsgBox("Is this a TWA or RFQ MS Access Shortcut? Filename: "
& Name1, _
' vbOKOnly, "Searching for MS Access Tooling App Shorcuts...")
'If X = vbYes Then
' F.DeleteFile .FoundFiles(i), True
'End If
Next i
Else
'MsgBox "There were no files found."
End If
.NewSearch 'Now search Network and get current filename for
ToolingServices.mde
.LookIn = DBAppPath 'Current network default directory
.SearchSubFolders = False
.Filename = "ToolingServices*.mde"
If .Execute() > 0 Then
'MsgBox "There were " & .FoundFiles.Count & _
'" file(s) found."
For i = 1 To .FoundFiles.Count
Name2 = F.GetFileName(.FoundFiles(i)) 'Used for Network filename
search(see Module)
' X = MsgBox("Is this a TWA or RFQ MS Access Shortcut? Filename: "
& Name2, _
' vbOKOnly, "Searching for MS Access Tooling App Shorcuts...")
'If X = vbYes Then
' F.DeleteFile .FoundFiles(i), True
'End If
Next i
Else
' MsgBox "There were no files found."
End If
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top