Embedding PDF file into a specific cell

mcomp72

Active Member
Joined
Aug 14, 2016
Messages
275
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2011
Platform
  1. Windows
  2. MacOS
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.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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