Hi guys.
Looking for an alternative to use in the following example for the with Application.FileSearch. I'm aware that this line of code became unsupported in 2007. We skipped the upgrade to 2007 and went from 2003 - 2010. Thank you in advance! Have put the whole section of code for context.
Code:
Option Explicit
Const DIALOG_NAME = "NameSakes”
Const OffencePath = "U:\Location"
Dim I As Integer
Dim NameSake As String
Dim FoundFiles As Integer
Dim FileName As String
Private Sub cmdOK_Click()
Application.ScreenRefresh
Application.ScreenUpdating = False
Namesake = txtNamesake.Text
If Len(Namesake) = 1 Then
Namesake = "00" + Namesake
ElseIf Len(Namesake) = 2 Then
Namesake = "0" + Namesake
End If
Namesake = "INF*" + Namesake
With Application.FileSearch
.FileName = Namesake + ".doc"
.LookIn = NamesakePath
.Execute
FoundFiles = .FoundFiles.Count
If FoundFiles < 1 Then
MsgBox (Namesake + " is not a valid Namesake." + vbCrLf + vbCrLf + _
"Please re-enter the Namesake number!"), vbOKOnly & vbInformation, _
DIALOG_NAME
' frmNameSake.Show
Else
FileName = .FoundFiles.Item(1) 'NamesakePath + "\" + Namesake + ".doc"
'FileName = NamesakePath + "\" + Namesake + ".doc"
Selection.InsertFile FileName
Unload frmNameSake
Application.Run "NextBookmark"
End If
End With
End Sub