Working with Ole Objects and Online Video

Inserting Ole Object

If you want Ole Object call DocumentBuilder.InsertOleObject. Pass to this method the ProgId explicitly with other parameters. The code example given below shows how to insert Ole Object into a document.

Set File Name and Extension when Inserting Ole Object

OLE package is a legacy and “undocumented” way to store embedded objects if the OLE handler is unknown. Early Windows versions such as Windows 3.1, 95 and 98 had Packager.exe application which could be used to embed any type of data into the document. Now, this application is excluded from Windows but MS Word and other applications still use it to embed data if the OLE handler is missing or unknown. OlePackage class allows accessing OLE Package properties. The code example given below shows how to set the file name, extension and display name for OLE Package.

Get Access to OLE Object Raw Data

The following code example demonstrates how to get OLE Object raw data using OleFormat.GetRawData() method.

Insert Ole Object as Icon

The following code example shows how to insert OLE Object as an icon. For this purpose, the DocumentBuilder class exposes the InsertOleObjectAsIcon method.

The following code example demonstrates how to inserts an embedded OLE object as an icon from a stream into the document.

Inserting Online Video

Online video can be inserted in MS Word from Insert tab > Online Video. You can insert online video into the document at the current location by calling DocumentBuilder.InsertOnlineVideo method. Four overloads of this method have introduced in DocumentBuilder class. The first one works with the most popular video resources and takes the URL to the video as a parameter. 

Simple insertion of online video from the following resources is supported:

–  –

The second overload works with all other video resources and takes embed Html code as a parameter:

The Html code for embedding video can vary between providers, consult your corresponding provider of choice for details. Note that the document will be automatically optimized for MS Word 2013 to show video.