Previewing Adobe file on record

Lochwood

Registered User.
Local time
Yesterday, 18:25
Joined
Jun 7, 2017
Messages
130
Hi All,

Here is my scenario.. I have created a form bound to a query and added a list box to go to the record when i highlight it from the list.

Each record has a hyperlink to a pdf document [Hyperlink] and i would like to show a preview of this document when i click on the corresponding record in the list box.

I have inserted ActiveX Control "Microsoft Web Browser" to the form and added the following code.

Private Sub WebBrowser0_GotFocus()
Me.WebBrowser0.Navigate [Hyperlink]
End Sub

Private Sub WebBrowser0_LostFocus()
Me.WebBrowser0.Navigate "about:blank"
End Sub

My issue is when i click on the control to get focus i am presented with the error: "The URL associated with this PDF document is malformed and may not display properly" i then click OK and it opens the PDF in the window.

All i can think of is that the full url path contains spaces but i dont know how to compensate for this in the code. Any help would be much appreciated
 
Dont use hyperlink field use short text. Hyperlink field has two parts. The one being displayed and the actual path and filename.
 
Dont use hyperlink field use short text. Hyperlink field has two parts. The one being displayed and the actual path and filename.

Worked a treat: thank you yet again.
 
I'm getting the same issue, but I'm not using hyperlink. I'm grabbing the filename e.g., sURL = "C:\Test\Test.pdf" and setting controlsource of the webbrowser to be = (" + Chr(39) + sURL + Chr(39) + ")" [I stole the Chr(39) from somewhere to get this to work]. Any ideas what's going on? I get "malformed URL" and then when I click okay, it opens.

Thanks!
 
I'm getting the same issue, but I'm not using hyperlink. I'm grabbing the filename e.g., sURL = "C:\Test\Test.pdf" and setting controlsource of the webbrowser to be = (" + Chr(39) + sURL + Chr(39) + ")" [I stole the Chr(39) from somewhere to get this to work]. Any ideas what's going on? I get "malformed URL" and then when I click okay, it opens.

Thanks!

Hi. Please post your actual code. Thanks.
 
can u try using sURL without those "(" and Chr(39).
I can't seem to find the "controlsource" property from webbrowser control.
you need to invoke its Navigate/Navigate2 method.

Me.webbrowser0.Object.Navigate sURL
 
Note that Subroutine expects parameter = pPageNo to know which page to go to in the PDF (this has worked just fine in the past)...

Code:
    Dim sURL As String
    
    Forms!usysfrmMain.[usysfrmMainPDFViewer].Form.PDFViewer.ControlSource = "=(" + Chr(39) + "about:blank" + Chr(39) + ")"
    
    sURL = "C:\Test\Test.pdf"
    If pPageNo > 1 Then
        sURL = sURL + "#toolbar=1&statusbar=1&navpanes=0" + "&page=" + CStr(pPageNo)
    Else
        sURL = sURL + "#toolbar=1&statusbar=1&navpanes=0" + "&page=1"
    End If
    sURL = sURL + "#zoom=100"

    DoCmd.OpenForm "usysfrmPDFViewer", acNormal
    Forms!usysfrmPDFViewer.PDFViewer.ControlSource = "(" + Chr(39) + sURL + Chr(39) + ")"
 
P.S. I have Adobe Reader DC installed so that's the default application running in the browser. Again, did not have an issue with this until very recently.
 
It looks like the Zoom parameter is the culprit? It used to work but now is giving me issues. So if I comment that out in setting up sURL, we seem okay.
 
sorry, no knowledge on PDFViewer syntax.
 
Actually, if I change #zoom to &zoom, I seem to have more success.
 

Users who are viewing this thread

Back
Top Bottom