Skip to content
本页内容

OLE 特性(OLEFormat)

代表 OLE 对象、ActiveX 控件或域的 OLE(而不是链接)特性

提示

WebOffice 当前不支持插入OLE对象。wps客户端插入的OLE对象,可以获取到此属性。

属性列表

属性说明
返回指定 OLE 对象的编程标识符(ProgID)。只读的字符串

ProgID

返回指定 OLE 对象的编程标识符(ProgID)。只读的字符串

语法

表达式.ActiveDocument.Shapes.Item(Index).OLEFormat.ProgID

或者 表达式.ActiveDocument.InlineShapes.Item(Index).OLEFormat.ProgID

表达式:文档类型应用对象

示例 1:通过 Shape 访问

js
//@file=base.docx
async function example() {
  await instance.ready()

  const app = instance.Application

  // 获取图形对象
  const shapes = await app.ActiveDocument.Shapes

  // 获取第 1 个图形对象
  const shape = await shapes.Item(1)

  // 返回一个 OLEFormat 对象,该对象表示指定的内嵌形状的 OLE 特征(而不是链接)。此为只读属性
  const OLEFormat = await shape.OLEFormat

  // 返回指定 OLE 对象的编程标识符(ProgID)。只读的字符串
  const ProgID = OLEFormat.ProgID
  console.log(ProgID)
}

示例 2:通过 InlineShape 访问

js
//@file=base.docx
async function example() {
  await instance.ready()

  const app = instance.Application

  // 获取图形对象
  const shapes = await app.ActiveDocument.InlineShapes

  // 获取第 1 个嵌入式图形对象
  const shape = await shapes.Item(1)

  // 返回一个 OLEFormat 对象,该对象表示指定的内嵌形状的 OLE 特征(而不是链接)。此为只读属性
  const OLEFormat = await shape.OLEFormat

  // 返回指定 OLE 对象的编程标识符(ProgID)。只读的字符串
  const ProgID = OLEFormat.ProgID
  console.log(ProgID)
}