hi
I have this code to open file based on cell G2 . it should open PDF extension
Private Sub Worksheet_Change(ByVal Target As Range)
Dim searchfile As String, fname As String
Dim oShell As Object
If Target.Address = "$G$2" Then
searchfile = "C:\Users\alhjh\Desktop\files\"
fname = Dir(searchfile & Target.Value & ".pdf")
If fname <> vbNullString Then
If MsgBox(fname & " available. Do you want to open this file?", vbYesNo + vbInformation, "Open pdf file?") = vbYes Then
Set oShell = CreateObject("WScript.Shell")
oShell.Run searchfile & fname
End If
End If
End If
End Sub
but doesn't work and no error
any suggestion to fix it please