DocumentBuilderInsertOleObject(String, String, Boolean, Boolean, Image) Method

Inserts an embedded or linked OLE object from a file into the document. Detects OLE object type using given progID parameter.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.8.0

Syntax

public Shape InsertOleObject(
	string fileName,
	string progId,
	bool isLinked,
	bool asIcon,
	Image presentation
)

Parameters

fileName
Type: SystemString
Full path to the file.
progId
Type: SystemString
ProgId of OLE object.
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 (.NetStandard 2.0).
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

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

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

// Insert ole object
Image representingImage = Image.FromFile(ImageDir + "Logo.jpg");
builder.InsertOleObject(MyDir + "Spreadsheet.xlsx", false, false, representingImage);

// Insert ole object with ProgId
builder.InsertOleObject(MyDir + "Spreadsheet.xlsx", "Excel.Sheet", false, true, null);

// Insert ole object as Icon
// There is one limitation for now: the maximum size of the icon must be 32x32 for the correct display
builder.InsertOleObjectAsIcon(MyDir + "Presentation.pptx", false, ImageDir + "Logo icon.ico",
    "Caption (can not be null)");

doc.Save(ArtifactsDir + "DocumentBuilder.InsertOleObject.docx");

See Also