Trying to make a macro to open a .pdf file whose file name contains the selected "Item number" in a spreadsheet. It will open in Internet Explorer. I'm getting close, I can open a file if its entire file name is the item number:
Sub OpenPDF()
Application.DisplayAlerts = False
X = ActiveCell.Row
Cells(X, 1).Select
Item = Cells(X, 1).Value
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "\\File Folder\" & Item & ".pdf"
End Sub
but can't figure out how to include a wildcard for file names begin with the item number. I have tried several variants on the following with no luck:
Sub OpenPDF()
Application.DisplayAlerts = False
X = ActiveCell.Row
Cells(X, 1).Select
Item = Cells(X, 1).Value
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "\\File Folder\" & Item & * & ".pdf"
End Sub
Sub OpenPDF()
Application.DisplayAlerts = False
X = ActiveCell.Row
Cells(X, 1).Select
Item = Cells(X, 1).Value
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "\\File Folder\" & Item & ".pdf"
End Sub
but can't figure out how to include a wildcard for file names begin with the item number. I have tried several variants on the following with no luck:
Sub OpenPDF()
Application.DisplayAlerts = False
X = ActiveCell.Row
Cells(X, 1).Select
Item = Cells(X, 1).Value
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "\\File Folder\" & Item & * & ".pdf"
End Sub