Skip to main content
All docs
.NET Framework 4.5.2+

NestedShapeCollection.AddOleObject(Stream, String, Image, PointF) Method

Adds an embedded OLE object to a shape group or a drawing canvas. The object is displayed in the document as an image.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v22.2.Core.dll

NuGet Package: DevExpress.RichEdit.Core


NestedShape AddOleObject(
    Stream stream,
    string progId,
    Image presentation,
    PointF location


Name Type Description
stream Stream

A stream that contains data to embed in the document.

progId String

Embedded content type. You can use constant fields of the OleObjectType class to set this value.

presentation Image

The image that displays OLE object content.

location PointF

An object that defines the object’s location (relative to the top left corner of the parent object). The Document.Unit property specifies measurement units.


Type Description

The OLE object in the group or drawing canvas.


The example below shows how to group two OLE objects. Use the ShapeCollection.InsertGroup method to create a shape group. The Shape.GroupItems property returns a collection of group elements. Call the AddOleObject methods to add OLE objects to the group.

Group OLE Objects

Document document = wordProcessor.Document;
// Set measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch;
// Insert a shape group.
Shape group = document.Shapes.InsertGroup(document.Range.Start);
// Access the collection of group items. 
var groupItems = group.GroupItems;
// Add the first OLE object to the group.
// This object contains data from an Excel worksheet.
using (Stream excelStream = File.Open(@"D:\ExcelWorkbook.xlsx", FileMode.Open))
    groupItems.AddOleObject(excelStream, OleObjectType.ExcelWorksheet,
        System.Drawing.Image.FromFile(@"Images\Spreadsheet.png"), new PointF(0f, 0f));
// Add the second OLE object to the group.
// The object links to an Excel chart sheet.
groupItems.AddOleObject(@"D:\ExcelChart.xlsx", OleObjectType.ExcelChart,
    System.Drawing.Image.FromFile(@"Images\ExcelChart.png"), new RectangleF(0.5f, 1.2f, 5f, 3.5f));
See Also