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.
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.