How can I embed a PDF in a Word Doc, and access that PDF with VBA?

Posted by Austin R on Stack Overflow See other posts from Stack Overflow or by Austin R
Published on 2012-09-10T15:36:41Z Indexed on 2012/09/10 15:37 UTC
Read the original article Hit count: 301

Filed under:
|
|
|
|

I have a word doc with some ActiveX buttons on it. When one of these buttons is pressed, a UserForm pops up with a corresponding PDF displayed, like so:

enter image description here This is exactly the behavior I want. However, the problem is that for this to work, the user of the word doc needs to have each of the PDFs saved on their machine as well. Here's the code for one of the buttons:

Private Sub AC1Button_Click()

    DisplayForm.AcroPDF1.LoadFile ("C:\Users\arose\Desktop\Security Control Doc\Sub PDFs\AC1.pdf")
    DisplayForm.Show

End Sub

As you can see, the path is hardcoded in. I need to be able to distribute this word doc without needing to distribute a bunch of PDFs along with it, so is there any way to embed PDFs in a word document in such a way that they're accessible by VBA?

I've discovered here that it's reasonably easy to embed a PDF in any office doc. And I've tried that:

enter image description here

But I can't figure out how to access that PDF object in my VBA code, in order to display it on the UserForm.

Any insight is appreciated, thanks!

© Stack Overflow or respective owner

Related posts about vba

Related posts about pdf