Home » excel » PDF Snippets in Word Doc with VBA?

PDF Snippets in Word Doc with VBA?

Posted by: admin April 23, 2020 Leave a comment

Questions:

So I have this Word doc with a bunch of ActiveX buttons, and whenever one of the buttons is pressed, a corresponding image pops up in a userform. It looks like this:
enter image description here

My problem is that each of the images that pops up is a screenshot of a portion of a PDF, but my users actually need to be able to select/copy the text presented.

Is there any good way to embed portions of a PDF file in a userform so that the text is select-able? It shouldn’t be edit-able, just select-able.

Or, worst case scenario, what might be the easiest way to copy text from the PDF myself and format it onto a userform?

Thanks!

How to&Answers:

I wouldn’t recommend using the image control for this if you want user to select the text from pdf.

Do this.

  1. Install Adobe Pdf Reader on your pc.
  2. Create a New Userform and place the AcroPDF1 and CommandButton control and you are done.

To Add the AcroPDF1 control see the screenshot

enter image description here

Next, draw the control on the Userform and place a CommandButton on the form

This is how your userform might look.

enter image description here

Put this code in the click event of the CommandButton1.

Option Explicit

Private Sub CommandButton1_Click()
    '~~> Change filename as applicable
    AcroPDF1.LoadFile "C:\Sample.Pdf"
End Sub

Now when you run it, the pdf will be displayed and you can select text. See screenshot below.

enter image description here