Skip to content
本页内容

文字框架(TextFrame)

表示 Shape 对象中的文字框架。 包含文本框中的文字框架的属性和控件的对齐方式和定位的文本框架的方法

文本

属性列表

属性说明
返回一个代表指定的文字框架中的文本的 TextRange 对象,此为只读属性
设置一个字符串,表示包含指定对象中的文本

TextRange

包含附加到形状的文本,以及用于操作文本的属性和方法

语法

表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().TextFrame.TextRange

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

示例

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

  const app = instance.Application

  const boxData = {
    Orientation: 0,
    Left: 0.1,
    Top: 0.1,
    Width: 0.1,
    Height: undefined,
    Color: '#f00',
    Size: 36,
    Scale: true
  }

  // 返回一个代表指定的文字框架中的文本的 TextRange 对象。此为只读属性
  const TextRange =
    await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox(boxData)
      .TextFrame.TextRange
  console.log(TextRange,'TextRange');
}

TextRange.Text

设置一个字符串,表示包含指定对象中的文本

语法

表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().TextFrame.TextRange.Text

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

示例

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

  const app = instance.Application

  const boxData = {
    Orientation: 0,
    Left: 0.1,
    Top: 0.1,
    Width: 0.1,
    Height: undefined,
    Color: '#f00',
    Size: 36,
    Scale: true
  }
   
  // 设置一个字符串,表示包含指定对象中的文本
  app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox(boxData).TextFrame.TextRange.Text =
    'WebOffice'
}