Excel VBA OLEObject.Add

Dear All,

I am using the following VBA code to embed PDF (non-linked) into an Excel file

ActiveSheet.OLEObjects.Add(Filename:=FilePath, Link:=False, DisplayAsIcon:=True, IconFileName:="C:\Windows\system32\packager.dll", IconIndex:=0, IconLabel:=IconName).Select

In our office everybody is using O365 so the EXCEL version we are using is the same (I checked). BUT still there are 3 different outcomes for the above mentioned VBA code:

a) Embedded file appears and the appearing name of the icon is the string defined as IconName

b) Embedded file appears, but there is no icon, a differen Logo appears and the appearing name of the embedded file is a temporary name given by the system like 6DC40FF5.pdf

c) Run-time error 1004 massage appears and the macro stops

How is it possible that the same VBA coded (using the same Excel versions) results in 3 different outcomes?

Any idea for solution?

Thanks a lot

Peter

September 7th, 2015 10:55am

Hi Peter,

This is the forum to discuss questions and feedback for Microsoft Excel, I'll move your question to the MSDN forum for Excel

http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

Regards,

Emi Zhang
TechNet Community Su

Free Windows Admin Tool Kit Click here and download it now
September 8th, 2015 2:05am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics