Display a PDF in the web browser control of an Access 2016 form

Have recently upgraded to Access 2016 and find that I can no longer display a PDF file in the web browser control on a form. I used to use VBA to display a particular PDF file stored on my computer...

          Forms!myForm!WebBrowser1.Object.Navigate ThisHyperlink

...where "ThisHyperlink" was a string something like "C:\Flyers\2016\04\15.pdf". Running this code would open the PDF in the "WebBrowser1" control window on the form. In Access 2016, however, the code insists on opening the PDF in a new window, outside of Access. So something has changed... but I can't figure out what. Any pointers would be appreciated. Thanks.

I don't have a solution, but I do know with A2013 we have a new webbrowser control with different capabilities.

Why not ShellExecute the PDF - albeit in a separate window?

-Tom.
Microsoft Access MVP
Phoenix, AZ

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Tom, thanks. Yes, of course I could simply have the PDF opened in a separate window. But the form I've designed contains (1) a subform that displays a recordset adjacent to (2) the web browser control window that displays the PDF. The nature of the work requires a lot of copying of text and numbers from the PDF into the recordset, and it's much more efficient to have them locked into place side by side in the same form. Plus, using VBA, I can have a different PDF displayed in the browser control depending on the contents of the recordset. It worked so smoothly, for so many years... sigh.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

There are other arguments in the Navigate method you might try, for example:

Forms!myForm!WebBrowser1.Object.Navigate ThisHyperlink , , _self


I'm not sure of the exact syntax, but the link below shows all the different arguments:

https://msdn.microsoft.com/en-us/library/aa752093(v=vs.85).aspx

Finally, there's also a Navigate2 Method available:

https://msdn.microsoft.com/en-us/library/aa752094%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

From my read, that's the "new" version, and therefore may work better with modern browsers (?).


Scott McDaniel, Access MVP 2009 - 2019
www.infotrakker.com
scott@infotrakker.com
(803) 221-0200
Skype: scottmcd9999

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Scott, thanks. I tried what you suggested, and I've tried every variation I can think of on the syntax, but nothing works -- the PDF always opens in a separate window, never in the Web Browser control. I tried both Navigate and Navigate2; the results were the same. (I can get a website URL to display, such as "http://www.microsoft.com", but I can't get a PDF file on my own PC to display the way I used to. I know the filepath is correct because, if I paste it into an external web browser, it opens the PDF fine! But I can't get it to open the PDF in the Web Browser control on my Access form.)

I don't know if this is related to my problem, but I can't get the "_self" argument to be accepted. If I simply type it in place, VBA rejects the underscore at the beginning of "_self" as an "invalid character"; if I put it in quotes, to signify that it's a string, then VBA won't compile the statement at all. The only way I can get the code to run is to supply only the hyperlink... and then, as I say, it ignores the Web Browser control on my form and simply opens the PDF in a separate new window.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Hi Robert,

Pardon me for jumping in but did you say if you fire up Internet Explorer and enter the URL to the file, the PDF opens inside IE? If yes, then I don't have an answer as well. But if the PDF opens in Acrobat, then I think it's a clue.

Just my 2 cents...

Just my 2 cents...

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Hope you don't mind me joining this discussion because I have the same problem having upgraded from Access 2010/Windows 7 to Access 2016/Windows 10. It is really frustrating because having a PDF file opening within a Web Browser Control in a form in Access is much appreciated by my colleagues as it means sticking to one program.

theDBGuy - If it helps, the PDF opens in Acrobat on my PC.

Any solutions gratefully received please!

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 21, 2024 Views 1,010 Applies to: