It open pdf based on cell value in cell F10. I would like to open a pdf file in certain folder only if the pdf file name start with F10 cell value. Below code work fine but works ONLY if the pdf file name is exactly the same in F10 cell value.
How can I open the pdf file if the pdf file name started with cell F10 value?
These codes open pdf file based on cell value, I need these codes open pdf who has numbers
How can I open the pdf file if the pdf file name started with cell F10 value?
These codes open pdf file based on cell value, I need these codes open pdf who has numbers
VBA Code:
Sub inv_PDF_File()
Dim FileNameRef As String, Prompt As String, myPath As String
Dim ret As Variant
FileNameRef = Application.WorksheetFunction.Text(Range("F10"), "0000")
myPath = "C:\"
On Error Resume Next
ThisWorkbook.FollowHyperlink myPath & FileNameRef & ".pdf"
If Err.Number <> 0 Then
Prompt = "Invoice Number [-]> " & FileNameRef & " <[-]" & vbNewLine & _
"NOT FOUND IN BELOW LOCATION OR LOCATION DOESN'T EXIT." & vbNewLine & _
"Click to explore folder location C:\"
Const TITLE = "PDF file Search"
Const BUTTONS = vbExclamation
Dim lRet As VbMsgBoxResult
Dim sLinksArray(0 To 0, 1) As String
sLinksArray(0, 0) = "C:\": sLinksArray(0, 1) = "C:\"
lRet = HyperlinkMsgBox(Prompt, sLinksArray, BUTTONS, TITLE)
End If
End Sub