DocumentBuilderInsertOleObject Method (String, Boolean, Boolean, Image)
Inserts an embedded or linked OLE object from a file into the document. Detects OLE object type using file extension.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.12
Syntax
public Shape InsertOleObject(
	string fileName,
	bool isLinked,
	bool asIcon,
	Image presentation
)

Parameters

fileName
Type: SystemString
Full path to the file.
isLinked
Type: SystemBoolean
If true then linked OLE object is inserted otherwise embedded OLE object is inserted.
asIcon
Type: SystemBoolean
Specifies either Iconic or Normal mode of OLE object being inserted.
presentation
Type: System.DrawingImage
Image presentation of OLE object. If value is null Aspose.Words will use one of the predefined images.

Return Value

Type: Shape
Shape node containing Ole object and inserted at the current Builder position.
Examples
Shows how to insert an OLE object into a document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Image representingImage = Image.FromFile(ImageDir + "Aspose.Words.gif");

// OleObject
builder.InsertOleObject(MyDir + "Document.Spreadsheet.xlsx", false, false, representingImage); 
//OleObject with ProgId
builder.InsertOleObject(MyDir + "Document.Spreadsheet.xlsx", "Excel.Sheet", false, false, representingImage);

doc.Save(ArtifactsDir + "Document.InsertedOleObject.docx");
Examples
Shows how to insert an OLE object into a document (.NetStandard 2.0).
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

using (SKBitmap representingImage = SKBitmap.Decode(ImageDir + "Aspose.Words.gif"))
{
    // OleObject
    builder.InsertOleObject(MyDir + "Document.Spreadsheet.xlsx", false, false, representingImage);
    //OleObject with ProgId
    builder.InsertOleObject(MyDir + "Document.Spreadsheet.xlsx", "Excel.Sheet", false, false,
        representingImage);
}

doc.Save(ArtifactsDir + "Document.InsertedOleObject.NetStandard2.docx");
See Also