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 2:53pm

Hi Emi,

thanks for your help. But something is not clear for me. You have already moved this question to the MSDN forum or I have to do it? Based on the link inserted in your answer I have tried to find my question, but I couldn't.

Thanks a lot

Peter

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

Hi Petya,

I have moved your question to MSDN Forum.

Regards,

Emi Zhang
TechNet Community Su

September 8th, 2015 9:22pm

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

Other recent topics Other recent topics