Embedding PDF file into a specific cell

mcomp72

Board Regular
Joined
Aug 14, 2016
Messages
157
I have written a macro to allow for embedding a PDF file into an Excel sheet. I want the icon for the file to show up in a certain cell. So far, so good, but I do have some questions.

But first, my code:

Code:
Range("AN5").Select

ActiveSheet.OLEObjects.Add(ClassType:="AcroExch.Document.DC", Link:=False, _
        DisplayAsIcon:=True, _
        IconIndex:=0, IconLabel:=NameForPDFIcon, _
        IconFileName:="C:\WINDOWS\Installer\{AC76BA86-7AD7-1033-7B44-AC0F074E4100}\PDFFile_8.ico").Activate
My questions:

1. I would like the icon to be in the center of Cell AN5, but instead it is justified to the top and left. If I add in Top and Left numbers into the OLEObjects.Add line, it will move the icon into cell A1. I can't figure out how to use Top & Left relative to the cell I have selected before Add line.

2. Whenever the file is embedded, the PDF opens. Is there a way to NOT have it open?

3. The IconFileName part has the very long string of letters and numbers. (I got this from recording a macro and then inserting a PDF into a sheet.) It looks like a registry address. If I use this file on another computer, will the icon show up there? I assume this long string of characters would be different on another computer? Anyone know how I can make it so this works no matter what computer it's running on? I plan to send this file to several other people when it's done.
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Watch MrExcel Video

Forum statistics

Threads
1,099,573
Messages
5,469,472
Members
406,655
Latest member
pwilson06

This Week's Hot Topics

Top