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

NameDescription
autoUpdateSpecifies whether the link to the OLE object is automatically updated or not in Microsoft Word.
clsidGets the CLSID of the OLE object.
iconCaptionGets 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.
isLinkReturns true if the OLE object is linked (when OleFormat.sourceFullName is specified).
isLockedSpecifies whether the link to the OLE object is locked from updates.
oleControlGets OleFormat.oleControl objects if this OLE object is an ActiveX control. Otherwise this property is null.
oleIconGets 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.
olePackageProvide access to OlePackage if OLE object is an OLE Package. Returns null otherwise.
progIdGets or sets the ProgID of the OLE object.
sourceFullNameGets or sets the path and name of the source file for the linked OLE object.
sourceItemGets or sets a string that is used to identify the portion of the source file that is being linked.
suggestedExtensionGets the file extension suggested for the current embedded object if you want to save it into a file.
suggestedFileNameGets the file name suggested for the current embedded object if you want to save it into a file.

Methods

NameDescription
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