OleFormat class
OleFormat class
Provides access to the data of an OLE object or ActiveX control. To learn more, visit the Working with Ole Objects documentation article.
Remarks
Use the Shape.oleFormat property to access the data of an OLE object. You do not create instances of the OleFormat class directly.
Properties
Name | Description |
---|---|
autoUpdate | Specifies whether the link to the OLE object is automatically updated or not in Microsoft Word. |
clsid | Gets the CLSID of the OLE object. |
iconCaption | Gets icon caption of OLE object. In case if the OLE object does not have an icon or a caption cannot be retrieved, returns an empty string. |
isLink | Returns true if the OLE object is linked (when OleFormat.sourceFullName is specified). |
isLocked | Specifies whether the link to the OLE object is locked from updates. |
oleControl | Gets OleFormat.oleControl objects if this OLE object is an ActiveX control. Otherwise this property is null. |
oleIcon | Gets the draw aspect of the OLE object. When true , the OLE object is displayed as an icon. When false , the OLE object is displayed as content. |
olePackage | Provide access to OlePackage if OLE object is an OLE Package. Returns null otherwise. |
progId | Gets or sets the ProgID of the OLE object. |
sourceFullName | Gets or sets the path and name of the source file for the linked OLE object. |
sourceItem | Gets or sets a string that is used to identify the portion of the source file that is being linked. |
suggestedExtension | Gets the file extension suggested for the current embedded object if you want to save it into a file. |
suggestedFileName | Gets the file name suggested for the current embedded object if you want to save it into a file. |
Methods
Name | Description |
---|---|
getRawData() | Gets OLE object raw data. |
save(stream) | Saves the data of the embedded object into the specified stream. |
save(fileName) | Saves the data of the embedded object into a file with the specified name. |
Examples
Shows how to extract embedded OLE objects into files.
let doc = new aw.Document(base.myDir + "OLE spreadsheet.docm");
let shape = doc.getShape(0, true);
// The OLE object in the first shape is a Microsoft Excel spreadsheet.
let oleFormat = shape.oleFormat;
expect(oleFormat.progId).toEqual("Excel.Sheet.12");
// Our object is neither auto updating nor locked from updates.
expect(oleFormat.autoUpdate).toEqual(false);
expect(oleFormat.isLocked).toEqual(false);
// If we plan on saving the OLE object to a file in the local file system,
// we can use the "SuggestedExtension" property to determine which file extension to apply to the file.
expect(oleFormat.suggestedExtension).toEqual(".xlsx");
// Below are two ways of saving an OLE object to a file in the local file system.
// 1 - Save it via a stream:
let writeStream = fs.createWriteStream(base.artifactsDir + "OLE spreadsheet extracted via stream" + oleFormat.suggestedExtension);
oleFormat.save(writeStream);
await finished(writeStream);
// 2 - Save it directly to a filename:
oleFormat.save(base.artifactsDir + "OLE spreadsheet saved directly" + oleFormat.suggestedExtension);
See Also
- module Aspose.Words.Drawing
- property Shape.oleFormat