View PDF in a form (1 Viewer)

rangersedge

Registered User.
Local time
Today, 13:12
Joined
Jun 13, 2014
Messages
82
I'm trying to view a pdf in a form if the file exists. My search has brought me to trying the WebBrowser control. I have it loading the file but it launches Adobe instead of just showing the PDF in the window on the form. Am I missing something?
 

MarkK

bit cruncher
Local time
Today, 11:12
Joined
Mar 17, 2004
Messages
8,186
You have not provided anything for us to troubleshoot. Presumably you have VBA code which produces an html file.
 

rangersedge

Registered User.
Local time
Today, 13:12
Joined
Jun 13, 2014
Messages
82
I've been reading that all I have to do is put a Webbrowser control on a form and point it to the file path of a PDF and it will display the PDF in the box. Instead it opens Adobe and the browser is just blank.

Is there another way to display a PDF inside a form? I have both Adobe AcrobatX and Adobe Reader installed but neither show up in the ActiveX Controls or the Reference tools in VBA.
 

MarkK

bit cruncher
Local time
Today, 11:12
Joined
Mar 17, 2004
Messages
8,186
There must be some code though. How to direct the web browser to the file? Like, remember in high school math, show your work! How do we troubleshoot where your process breaks down if you don't show your process?
point it to the file path of a PDF
How, exactly, do you do that?
 

rangersedge

Registered User.
Local time
Today, 13:12
Joined
Jun 13, 2014
Messages
82
I'm only using VBA to create the file path. I use this code to find the file...

Public Function GetDBPath() As String
GetDBPath = CurrentProject.Path & "\" & Me.SetNumber
End Function

I then have this to put the path into a text box for troubleshooting and to ensure the path is correct.

Private Sub Form_Current()
Dim Path As String

Path = GetDBPath
Me.Textbox1 = Path

Then I put a WebBrowser control on the form. I've tried setting the control source to the text box and even tried using the VBA code to set the path like this...

WebBrowser1.ControlSource(Me.Textbox1)

I can get the correct address in the text box and all the codes work. The problem is
that it opens up Adobe instead of just displaying the PDF in the window.
 

TJPoorman

Registered User.
Local time
Today, 12:12
Joined
Jul 23, 2013
Messages
402
Try this for your Current Event:

Code:
Private Sub Form_Current()
Dim Path As String

Path = GetDBPath
Me.Textbox1 = Path

Me.WebBrowser1.Object.Navigate Path
End Sub
 

MarkK

bit cruncher
Local time
Today, 11:12
Joined
Mar 17, 2004
Messages
8,186
See how TJP is calling the Navigate() method of the web browser object, and passing in the path, which is the URL?

So once you are not worried about debugging anymore, you can refactor to . . .
Code:
Private Sub Form_Current()
   Me.WebBrowser1.Object.Navigate CurrentProject.Path & "\" & Me.SetNumber
End Sub
 

rangersedge

Registered User.
Local time
Today, 13:12
Joined
Jun 13, 2014
Messages
82
When I tried to use the Navigate command it didn't show up in the list of commands. When I typed it in anyway it gave an error saying that is not a valid command. This is the first time I've seen the Object put in front like that. I will give it a try.
 

rangersedge

Registered User.
Local time
Today, 13:12
Joined
Jun 13, 2014
Messages
82
The WebBrowser is still not showing the PDF. All it does is open Adobe to full screen and shows the PDF that way. I'm trying to get the PDF to view in the form itself. Navigating to the file is the easy part. The part I can't figure out is to make it stop opening Adobe and just show the PDF.
 

rangersedge

Registered User.
Local time
Today, 13:12
Joined
Jun 13, 2014
Messages
82
That must have been the problem. I reinstalled Adobe Reader and then finally found the extension in the IE under the tab "Run without permission". Took to searching but now it works.
 

rangersedge

Registered User.
Local time
Today, 13:12
Joined
Jun 13, 2014
Messages
82
Would you happen to know how to make the PDF stay full screen inside the webbrowser? When I go to a new record it automatically has the PDF controls.
 

MarkK

bit cruncher
Local time
Today, 11:12
Joined
Mar 17, 2004
Messages
8,186
It appears to me that this kind of thing is browser dependent, and in that case your google is as good as mine, sorry,
 

rangersedge

Registered User.
Local time
Today, 13:12
Joined
Jun 13, 2014
Messages
82
I have found this code to make the PDF fullscreen by setting the PDF viewer toolbar and nav panes to 0. Doesn't seem to work on Access 2013 with Adobe Reader XI

webBrowserControl.Navigate(filePath & "#toolbar=0&navpanes=0&scrollbar=0")
 

Users who are viewing this thread

Top Bottom