Displaying a PDF file via VBA within Microsoft Access 2010 in 2003 mode without irritating Microsoft confirmation

I'm trying to display a PDF file with VBA but I get this irritating dialog wanting confirmation. I'm using Access 2010 in 2003 mode. I wanted to allow users to do this without creating a form with an embedded browser control

Since I can't get rid of the confirmation, I'm trying to use a form to contain the PDF file. I found an ActiveX browser control that I should be able to use in a form but the version of browser control doesn't seem to work as I can't find how to define the file link.

Thanks so much!!
pabrannPresidentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
I *think* you could use a webbrowser control to display it, however I also think that the webbrowser control was only added in 2010. Its been quite a while since I used 2003, and I don't have a copy installed anymore.

An alternative is to get rid of the warning message, which you should be able to do with the link here;
http://access.mvps.org/access/api/api0018.htm
Jeffrey CoachmanMIS LiasonCommented:
dialog wanting confirmation.
...and the message says...?

This fairly common code works fine for me in all versions of Access that I have tried it in...
(Obviously you will have to use your specific file location for your adobe PDF program executable)
Private Sub Command0_Click()
Dim varCmd As Variant
varCmd = Shell("C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" & " " & "C:\YourFolder\YourPDF.PDF", vbNormalFocus)
End Sub

Open in new window

Jeffrey CoachmanMIS LiasonCommented:
FWIW, ...this is fairly standard code to display a PDF in a form, using a web browser control...

Me.WebBrowser1.Navigate "C:\YourFolder\Yourpdf.pdf"
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

Jeffrey CoachmanMIS LiasonCommented:
sorry:
Me.WebBrowser1.Navigate "C:\YourFolder\Yourpdf.pdf"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pabrannPresidentAuthor Commented:
When I execute the following, the pdf displays properly after the irritating confirmation.

FollowHyperlink path2 & ".pdf", , True

I tried your code:
varCmd = Shell("C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" & " " & path2 & ".PDF", vbNormalFocus)

and I get an error saying the file cannot be foundDisplay-PDF-via-VBA.png
Jeffrey CoachmanMIS LiasonCommented:
You did not post the code you used, ...but since the code opened Adobe, ...then the fist part of the snippet is working...
You will only get that error when you don't properly specify the actual full path to your PDF file...

...Perhaps "Path2" already contains the extension?..., or it has an incorrect drive, ...etc)
Always *Keep things Simple* to test...
Forget variables for now, ...to test:
Drop a simple PDF on your root directory, then...please type out the full path, filename and extension...
(as I did in my example...)
For example...:
'varCmd = Shell("C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" & " " & "C:\Test.PDF", vbNormalFocus)

Only when this is working can you add a more complex path...
Then add any variables...

Jeff
Jeffrey CoachmanMIS LiasonCommented:
Since you never mentioned the actual error message, ...I will presume that it is the:
    "Security Concern, ....Location my be unsafe"
...message.

Follow Hyperlink was only ever created for hyperlinks specifically, ...not really for file locations.
Depending on your environment, it might work for files, ...or it might not.

There is code to disable the messsage:
https://support.microsoft.com/en-us/kb/925757
...but this may open you up to security issues.

JeffCoachman
pabrannPresidentAuthor Commented:
Your solution worked perfectly. Thank you very much!
Jeffrey CoachmanMIS LiasonCommented:
Great...

Glad I could help
;-)
Jeff
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.