How do I assign an embedded PDF to an AcroPDF Control on a form?

Wesnet

New Member
Joined
Aug 3, 2009
Messages
10
Hi everyone - I have a rather obscure problem here that someone may be able to help with although it won't surprise me if no-one knows the answer:

My goal is to have a form that displays (among other controls) a PDF document which has previously been embedded into the spreadsheet.

I can embed the PDF document in vba as follows:

Code:
ActiveSheet.OLEObjects.Add Filename:=Range("PDFFile"), DisplayAsIcon:=True

where the Range PDFFile contains a filename such as C:\Myfile.PDF

I also have a form that can display a PDF document nicely using the code:

Code:
frmMyForm.pdfMyPDF.src = Range("PDFFile")
frmMyForm.Show

where frmMyForm is a userform and pdfMyPDF is an "Adobe PDF Reader" control. This control appears in the list of additional controls you can add when right clicking the toolbox in Visual Basic.

And so in a nutshell...

I don't want the userform to display the PDF from the external PDF file (I can already do this in any case) - I need it to display the PDF from the embedded PDF file. What code do I need to do this (-ie- to use the embedded PDF as the source for the PDF file on the userform?)

Thank you.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Ok - I found something useful:

If I embed the PDF on a new sheet (by Insert, Object, Adobe Acrobat Object), then I can at least reference the embedded object as follows:

Code:
Private Sub Worksheet_Activate()
    ActiveSheet.Shapes(1).Select
    Selection.Verb Verb:=xlPrimary
End Sub

So it appears the embedded PDF is stored as a shape... The Verb line makes the PDF open in Acrobat reader (not what I want).

Now whenever I click on the new sheet, the PDF will open up. The question is though, how can I make the same PDF appear on a form? Once again, I can do this if I reference a file:

Code:
frmMyForm.pdfMyPDF.src = "C:\myfile.pdf"

but I what I need is something like:

frmMyForm.pdfMyPDF.src = <The embedded PDF file in my spreadsheet!>

Any ideas anyone???
 
Upvote 0
Oops - that didn't appear correctly. It should have read:

frmMyForm.pdfMyPDF.src = [The embedded PDF] 'Instead of a filename

Maybe even the .src is wrong? It works for a filename, but I am not sure what else I could use...
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top