Skip to main content
All docs

ShapeCollection.InsertOleObject(DocumentPosition, String, DocumentImageSource) Method

Inserts an OLE object that contains a link to the specified file. The object is displayed in the document as an image.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v24.1.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation


Shape InsertOleObject(
    DocumentPosition pos,
    string fileName,
    DocumentImageSource presentation


Name Type Description
pos DocumentPosition

The position of the object’s anchor.

fileName String

A path to the file associated with the OLE object.

presentation DocumentImageSource

The source for the image that displays OLE object content.


Type Description

The OLE object added to the document.


The following example adds a linked OLE object to the document:

Document document = wordProcessor.Document;
// Insert an OLE object. Link it to an Excel worksheet.
Shape oleObject = document.Shapes.InsertOleObject(document.CreatePosition(1780), @"D:\ExcelWorkbook.xlsx",
// Specify the object position on the page.
oleObject.RelativeHorizontalPosition = ShapeRelativeHorizontalPosition.Column;
oleObject.RelativeVerticalPosition = ShapeRelativeVerticalPosition.Paragraph;
oleObject.Offset = new PointF(0, 0);
// Specify how text wraps around the object. 
oleObject.TextWrapping = TextWrappingType.TopAndBottom;

Open the document in Microsoft® Word® and double-click the image to open the file associated with the OLE object.

Insert a Linked OLE Object

See Also