I am running Excel 2016, which may be relevant if the below is a compatibility issue...
In short, I am trying to display a PDF, embedded in a UserForm in Excel.
I have a UserForm, say UserForm1
.
I have enabled the following extra references:
- Microsoft Visual Basic for Applications Extensibility 5.3
- Adobe Acrobat Browser Control Type Library 1.0
This allows me to add the Adobe PDF Reader
as an "Additional Control"
The control appears as a hatched box icon (bottom left), which I'm not sure it's meant to. Then if I try to add one of these objects to UserForm1
(both programmatically and in design view) it gives me an error
Element not found
For reference, the relevant lines of VBA I was using were:
Dim PDFviewer As AcroPDF
Set PDFviewer = PDForm.Frame1.Controls.Add("AcroPDF.PDF.1")
Which I took from this Adobe forums thread: https://forums.adobe.com/thread/1065554
Resources online suggest it might be that the AcroPDF control is no longer supported. If so, is there another way to achieve what I want?
As an alternative to using the
AcroPDF
, try using theWebBrowser
Object.It requires including the additional control
Microsoft Web Browser
Add a WeBrowser on the UserForm named
WebBrowser1
You can just
.Navigate
to the PDF directly, but, to quote my comment:"It's safer to use the html part, depending on the machine settings, sometimes direct navigation will initiate download instead of display."