After researching various methods to open a PDF file such as Shellexecute and hyperlink I found a helpful post from Kiwiman going back to 2008 with some success. Although I can get it to run correctly if I provide the full file location and file name I cannot get it to run correctly when pulling the data from a textbox. I am trying to get this to match the OID value within a text box and then to search a given file location for the PDF starting with the number contained within the filename provided by the OID value.
The code I am using is as follows
Public Sub OpenDocument(DocPath As String)
Dim A As Long
A = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & DocPath, vbMaximizedFocus)
End Sub
MsgBox Dir("D:" & [OID] & "*") 'Returns the correct file location and filename
Call OpenDocument("D:\12078 My Test.pdf") 'Opens the pdf document correctly
Call OpenDocument(Dir("D:" & [OID] & "*")) 'Will NOT open pdf document and does not return an error
Any help would be appreciated.
The code I am using is as follows
Public Sub OpenDocument(DocPath As String)
Dim A As Long
A = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & DocPath, vbMaximizedFocus)
End Sub
MsgBox Dir("D:" & [OID] & "*") 'Returns the correct file location and filename
Call OpenDocument("D:\12078 My Test.pdf") 'Opens the pdf document correctly
Call OpenDocument(Dir("D:" & [OID] & "*")) 'Will NOT open pdf document and does not return an error
Any help would be appreciated.
Last edited: