fullstackvale-2571 avatar image
0 Votes"
fullstackvale-2571 asked fullstackvale-2571 edited

Exception System.Runtime.InteropServices.COMException (0x800A03EC): Cannot insert object

In Windows form Application, Facing this exception System.Runtime.InteropServices.COMException (0x800A03EC): Cannot insert object.

at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)

at Microsoft.Office.Interop.Excel.Shapes.AddOLEObject(Object ClassType, Object Filename, Object Link, Object DisplayAsIcon, Object IconFileName, Object IconIndex, Object IconLabel, Object Left, Object Top, Object Width, Object Height)

Office 365 and OS windows 10
Application:Windows Application
Target framework: .NET Framework 4.5
Reference: Microsoft.Office.Interop.Excel (version:

I write a function in window application that add pdf file into Excel sheet.
But I got this error System.Runtime.InteropServices.COMException (0x800A03EC): Cannot insert object
at method AddOLEObject() .

             //Insert ISO_LAYOUT pdf-drawing as object
             if (utilities.ctos(drCurrent["drawings"]) != "" && IncludeDetailAttachments)
                         Excel.Shape shape = wsCurrent.Shapes.AddOLEObject(
                         ClassType: Type.Missing,
                         Filename: copyToFile,
                         Link: false,
                         DisplayAsIcon: true,
                         IconFileName: "",
                         IconIndex: 0,
                         IconLabel: "",
                         Left: Type.Missing,
                         Top: Type.Missing,
                         Width: Type.Missing,
                         Height: Type.Missing);
                         shape.Fill.ForeColor.RGB = 500;
                         //shape.Fill.UserPicture(WSCommon.Properties.Settings.Default.surfaceDrawingPath + "Binders.png");
                         shape.Width = 15;
                         shape.Height = 17;
                         shape.Left = (float)iconCell.Left + (float)345;
                         shape.Top = (float)iconCell.Top + (float)1;

                         shape.Locked = false;
                         shape.Name = "Detail attachment " + drCurrent["lv1"].ToString() + drCurrent["lv2"].ToString() + drCurrent["lv3"].ToString() + drCurrent["lv4"].ToString() + drCurrent["lv5"].ToString() + drCurrent["lv6"].ToString();


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @fullstackvale-2571,
In order to solve your problem more accurately and effectively, please provide more information and some code to reproduce the situation.
Meanwhile, there is a similar thread and you can refer to it.
Best Regards,
Daniel Zhang

0 Votes 0 ·

Hi @DanielZhang-MSFT , I have updated the query .
Please have a look. I tried with most of stuff available online ,but couldn't get any success yet.
Mostly this error occurred while adding pdf file into Excel sheet at line no. 4 method AddOLEObject() .

Windows Application
.NET Framework 4.5
Reference: Microsoft.Office.Interop.Excel (version:

0 Votes 0 ·

Hi @fullstackvale-2571
You can check if PDF files support OLE by manually inserting it into a simple Excel file.
If not successful, I suggest you follow thiag0's code example to embed a PDF file in Excel.
Best Regards,
Daniel Zhang

0 Votes 0 ·

0 Answers