Trying to test the code. But errors on undeclared variable txtFilePath. Where is this variable declared and how is it set? Also, VBA doesn't recognize ShellExecute function. I had to find this on web.
I got this to work:
Code:
Public Declare Function ShellExecute _
Lib "shell32.dll" _
Alias "ShellExecuteA" ( _
ByVal Hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long
Private Sub ViewFile()
Dim Task As Long
Task = ShellExecute(0, "Open", "C:\Users\June\Image.jpg", "", "", 0)
End Sub
Here is an alternative to calling the Shell: http://allenbrowne.com/func-GoHyperlink.html