DocumentBuilderInsertOleObjectAsIcon Method

Inserts an embedded or linked OLE object as icon into the document. Allows to specify icon file and caption. Detects OLE object type using file extension.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.4
public Shape InsertOleObjectAsIcon(
	string fileName,
	bool isLinked,
	string iconFile,
	string iconCaption


Type: SystemString
Full path to the file.
Type: SystemBoolean
If true then linked OLE object is inserted otherwise embedded OLE object is inserted.
Type: SystemString
Full path to the ICO file. If the value is null, Aspose.Words will use a predefined image.
Type: SystemString
Icon caption.

Return Value

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

Image representingImage = Image.FromFile(ImageDir + "Logo.jpg");

// Insert ole object
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 + "Spreadsheet.xlsx", false, ImageDir + "Logo icon.ico",
    "Caption (can not be null)");

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