Back to Devexpress

NestedShapeCollection.AddOleObjectAsIcon(String, String, DocumentImageSource, PointF) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-nestedshapecollection-dot-addoleobjectasicon-x28-string-string-documentimagesource-pointf-x29.md

latest5.2 KB
Original Source

NestedShapeCollection.AddOleObjectAsIcon(String, String, DocumentImageSource, PointF) Method

SECURITY-RELATED CONSIDERATIONS

Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.

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

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
NestedShape AddOleObjectAsIcon(
    string fileName,
    string progId,
    DocumentImageSource icon,
    PointF location
)
vb
Function AddOleObjectAsIcon(
    fileName As String,
    progId As String,
    icon As DocumentImageSource,
    location As PointF
) As NestedShape

Parameters

NameTypeDescription
fileNameString

A path to the file associated with the OLE object.

| | progId | String |

The file type. You can use constant fields of the OleObjectType class to set this value.

| | icon | DocumentImageSource |

An object used to load the icon for the OLE object.

| | 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.

|

Returns

TypeDescription
NestedShape

The OLE object in the group or drawing canvas.

|

Remarks

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 AddOleObjectAsIcon methods to add OLE objects to the group.

csharp
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);
// Specify the group position relative to the left and top edges of the page. 
group.Offset = new PointF(1f, 6f);
// Access the collection of group items. 
var groupItems = group.GroupItems;
// Add the first OLE object to the group.
groupItems.AddOleObjectAsIcon(@"D:\ExcelWorkbook.xlsx", OleObjectType.ExcelWorksheet, 
    DocumentImageSource.FromFile(@"Images\Excel.ico"), new PointF(0f, 0f));
// Add the second OLE object to the group.
groupItems.AddOleObjectAsIcon(@"D:\PowerPointPresentation.pptx", OleObjectType.PowerPointPresentation,
    DocumentImageSource.FromFile(@"Images\PowerPoint.ico"), new PointF(1.5f, 0f));
vb
Dim document As Document = wordProcessor.Document
' Set measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch
' Insert a shape group.
Dim group As Shape = document.Shapes.InsertGroup(document.Range.Start)
' Specify the group position relative to the left and top edges of the page. 
group.Offset = New PointF(1F, 6F)
' Access the collection of group items. 
Dim groupItems As GroupShapeCollection = group.GroupItems
' Add the first OLE object to the group.
groupItems.AddOleObjectAsIcon("D:\ExcelWorkbook.xlsx", OleObjectType.ExcelWorksheet, _ 
    DocumentImageSource.FromFile("Images\Excel.ico"), New PointF(0F, 0F))
' Add the second OLE object to the group.
groupItems.AddOleObjectAsIcon("D:\PowerPointPresentation.pptx", OleObjectType.PowerPointPresentation, _ 
    DocumentImageSource.FromFile("Images\PowerPoint.ico"), New PointF(1.5F, 0F))

See Also

NestedShapeCollection Interface

NestedShapeCollection Members

DevExpress.XtraRichEdit.API.Native Namespace