跳到主要内容

CreateOleObject

使用指定的参数创建 OLE 对象。

语法

expression.CreateOleObject(sImageSrc, nWidth, nHeight, sData, sAppId);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
sImageSrc必需string要插入的图像来源(目前仅支持网络 URL 或 Base64 编码的图像)。
nWidth必需EMU以英制度量单位表示的 OLE 对象宽度。
nHeight必需EMU以英制度量单位表示的 OLE 对象高度。
sData必需stringOLE 对象字符串数据。
sAppId必需string与当前 OLE 对象关联的应用程序 ID。

返回值

ApiOleObject

示例

此示例创建 OLE 对象并将其插入幻灯片。

// How to create an Ole object.

// Add an Ole object to the slide.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const oleObject = Api.CreateOleObject(
'https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png',
150 * 36000, 150 * 36000,
'https://youtu.be/SKGz4pmnpgY',
'asc.{38E022EA-AD92-45FC-B22B-49DF39746DB4}'
);
oleObject.SetSize(200 * 36000, 130 * 36000);
oleObject.SetPosition(70 * 36000, 30 * 36000);
slide.AddObject(oleObject);