I have a folder with 167 pdf files named with a persons name.
such as some of the follwing:
Adthes, Dani HandWritten.pdf
or
Athur, Kater - FFT - 7-29-11.pdf
the names are Adthes, Dani and Athur, Kater
The table has the names but not the extra stuff in the file name. I don't want to edit every file name.
currently my code does not open anything.
the code however finds 1 document since the code .FoundFiles.Count has a 1 in it when I pause it and hold my mouse over the coding.
Since it found 1 pdf file, is there anyway to extract the file name that I can pass that to the ShellExecute. Sicne it seems Adthes, Dani*.pdf will not open?
Or any other ideas how to make this work?
I eventually need to email each person their exact pdf with their name to their email address in the table. So I want to automate this as much as possible.
TIA
DougP
such as some of the follwing:
Adthes, Dani HandWritten.pdf
or
Athur, Kater - FFT - 7-29-11.pdf
the names are Adthes, Dani and Athur, Kater
The table has the names but not the extra stuff in the file name. I don't want to edit every file name.
currently my code does not open anything.
the code however finds 1 document since the code .FoundFiles.Count has a 1 in it when I pause it and hold my mouse over the coding.
Code:
Dim FiletoOpen, StudentName, FullPath As String
StudentName = Me.Childs_Last_Name & ", " & Me.Childs_First_Name
FullPath = "S:\Student Fee Folder\returned E-forms from parents\Original files\"
FiletoOpen = FullPath & StudentName & "*" & ".pdf"
With Application.FileSearch
.NewSearch
.LookIn = FullPath
.FileName = StudentName & "*" & ".pdf"
If .Execute(SortBy:=msoSortByLastModified, SortOrder:=msoSortOrderDescending) > 0 Then
If .FoundFiles.Count > 1 Then
'launch Windows Explorer
RetVal = ShellExecute(hwnd, "open", BrowserExec, FullPath, Dummy, SW_SHOWNORMAL)
Else
'just open the file
RetVal = ShellExecute(hwnd, "open", FiletoOpen, "", FullPath, SW_SHOWNORMAL)
End If
Else
MsgBox FileName, vbInformation, "File Not found"
RetVal = ShellExecute(hwnd, "open", BrowserExec, FullPath, Dummy, SW_SHOWNORMAL)
End If
Since it found 1 pdf file, is there anyway to extract the file name that I can pass that to the ShellExecute. Sicne it seems Adthes, Dani*.pdf will not open?
Or any other ideas how to make this work?
I eventually need to email each person their exact pdf with their name to their email address in the table. So I want to automate this as much as possible.
TIA
DougP