VB Code FileSearch

T

tsraj

Could any one please tell me what is wrong with this code
Private Sub Command95_Click()
Dim sDocNo As String
Dim sPath As String
Dim I As Integer

If Not IsNull(Me.Field5) Then
sDocNo = Me.Field5
sPath = "E:\Disc 1\"
With Application.FileSearch
.NewSearch
.lookin = sPath
.SearchSubFolders = True
.FileName = "*" & sDocNo & "*.pdf"
If .Execute(msoSortByFileName, msoSortOrderDescending) <> 0 Then
For I = 1 To .FoundFiles.Count
If MsgBox(.FoundFiles(I), vbYesNo, "Do you want to open this
file") = vbYes Then
Application.FollowHyperlink .FoundFiles(I), , True
Exit For
End If
Next I
Else
MsgBox sPath & "*" & sDocNo & "*.pdf", vbOKOnly, "File not found"
End If
End With

Else
MsgBox "Enter Inv No"
End If
End Sub

Thanks for helping.
 
D

David W. Fenton


I've coded a class module to replace the FileSearch object. I keep
intending to update it and document it, but a version from late May
is available here:

http://dfenton.com/DFA/download/Access/FileSearch.zip

I've done significant work on it as part of an application, but
never gotten round to going back and integrating those changes into
my sample code db. At one point I started writing up a web page to
document it, but got sidetracked with about a bazillion other
things.
 

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