本文介绍与演示文稿Shape相关的API。
Shapes
ActivePresentation.SlideShowWindow.View.Slide.Shapes
获取指定幻灯片中的所有Shape对象集合。
JS-SDK V1.1.10及以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取指定幻灯片中的所有Shape对象集合 const shapes = await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes; }
方法
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddPicture()
通过AddPicture()
方法,您可以在当前幻灯片中插入图片。
JS-SDK V1.1.10及以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddPicture({ FileName, LinkToFile, SaveWithDocument, Left, Top, Width, Height, Scale })
表达式:文档类型应用对象
参数
属性
数据类型
是否必填
描述
FileName
String
是
图片对象。可以是Blob文件对象或者URL链接。
LinkToFile
Enum
是
是否将图片链接到创建该图片的文件。更多信息,请参见MsoTriState。
SaveWithDocument
Enum
是
是否将已链接的图片插入到文档一起保存。如果参数
LinkToFile
取值为msoFalse
,则此参数必须为msoTrue
,更多信息,请参见MsoTriState。Left
Number
是
图片左边缘相对于幻灯片左边缘的位置。单位为百分比,取值范围为0~1。
说明取值小于0或大于1图片将插入幻灯片页面区域外。
Top
Number
是
图片上边缘相对于幻灯片上边缘的位置。单位为百分比,取值范围为0~1。
说明取值小于0或大于1图片将插入幻灯片页面区域外。
Width
Number
否
图片的宽度。单位为百分比,默认值为1,表示图片原宽度。
Height
Number
否
图片的高度。单位为百分比,默认值为1,表示图片原高度。
Scale
Boolean
否
是否按幻灯片比例计算插入图片的宽高和坐标。取值范围如下:
false(默认):否。
true:是。
示例
async function example() { await instance.ready(); const app = instance.Application; //在当前幻灯片中插入图片 await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddPicture({ FileName: 'https://image.developer.aliyundoc.com/storage/000000003682-2-tps-799-531.png', LinkToFile: -1, SaveWithDocument: 0, Left: 0.1, Top: 0.1, Width: 0.3, Height: 0.3, Scale: true, }); }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddMediaObject()
通过AddMediaObject()
方法,您可以插入音视频对象。
JS-SDK V1.1.14及以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddMediaObject({ Type, FileName, File, Url, LinkToFile, Left, Top, Width, Height })
表达式:文档类型应用对象。
参数
属性
数据类型
必填
说明
Type
String
是
文件类型:'audio': 音频; 'video': 视频
FileName
String
是
文件名
File
Object
否
要在其中创建 OLE 对象的文件(可以是 Blob 文件对象或者 File文件对象)
Url
String
否
文件的链接(支持Base64)
LinkToFile
Enum
是
确定是否将音视频链接到从中创建该音视频的文件,详细可参考MsoTriState。
Left
Number
否
对象左边缘相对于幻灯片左边缘的位置
Top
Number
否
对象上边缘相对于幻灯片上边缘的位置
Width
Number
否
对象的宽度
Height
Number
否
对象的高度
async function example() { await instance.ready(); const app = instance.Application; // 将视频插入到当前 PPT 中 await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddMediaObject({ Type: 'video', FileName: 'audio.mp4', Url: 'https://res1.wpsacdm.cache.wpscdn.cn/videos/57da3d14aee8307bab5fa529503adba4-min.mp4', //来自[wps学堂]的视频 LinkToFile: 0, Left: 100, Top: 200, Width: 300, Height: 300, }); }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox()
通过AddTextbox()
方法,您可以创建一个文本框。
JS-SDK V1.1.10及以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox({ Orientation, Left, Top, Width, Height, Color, Size, Scale, Bold, Italic, StrikeThrough, AlignMode })
表达式:文档类型应用对象
参数
属性
数据类型
是否必填
描述
Orientation
Enum
是
文本字体方向。更多信息,请参见MsoTriState。
Left
Number
是
文本框左边缘相对于幻灯片左边缘的位置。单位为百分比,取值范围为0~1。
说明取值小于0或大于1文本框将插入幻灯片页面区域外。
Top
Number
是
文本框上边缘相对于幻灯片上边缘的位置。单位为百分比,取值范围为0~1。
说明取值小于0或大于1文本框将插入幻灯片页面区域外。
Width
Number
否
文本框的宽度,单位为百分比。默认值为0.05。
Height
Number
否
文本框的高度。单位为百分比。默认值为0.25。
Color
String
否
文本的颜色。默认值为#000000,表示黑色。
Size
Number
否
文本字体的大小。默认值为18。
Scale
Boolean
否
是否自动扩展文本框宽度。取值范围如下:
false(默认):否。
true:是。
Bold
Boolean
否
文本是否加粗。取值范围如下:
false(默认):否
true:是。
Italic
Boolean
否
文本是否斜体。取值范围如下:
false(默认):否
true:是。
StrikeThrough
Boolean
否
文本是否加删除线。取值范围如下:
false(默认):否
true:是。
AlignMode
Number
否
文本对齐方式。取值范围如下:
1(默认):左对齐。
2:居中对齐。
3:右对齐。
4:两端对齐。
5:分散对齐。
返回值
返回一个Shape对象,表示新的文本框。
示例
async function example() { await instance.ready(); const app = instance.Application; //创建一个文本框 const textBox = await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox({ Orientation: 0, Left: 0.1, Top: 0.1, Width: 0.1, Height: 0.1, Color: '#f00', Size: 36, Scale: true }); textBox.TextFrame.TextRange.Text = '1245'; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.ReplacePicture()
通过ReplacePicture()
方法,您可以替换幻灯片中选中的图片。
JS-SDK V1.1.10及以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.ReplacePicture({ FileName, IsKeepShapeSize })
表达式:文档类型应用对象
参数
属性
数据类型
是否必填
描述
FileName
String/Object
是
图片源。可以是Blob文件对象或者URL链接,用以替换选中的图片。
IsKeepShapeSize
Boolean
否
是否保持源图片的比例。取值范围如下:
true(默认):源图片的大小不会改变。
false:根据选中图片的宽高比例重新设置源图片的宽高。
示例
async function example() { await instance.ready(); const app = instance.Application; // 替换 PPT 中选中的图片 await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.ReplacePicture({ FileName: 'https://img8.file.cache.docer.com/storage/1626952237972828328/0e7c3a748ed2d065749b9659f54b679e.jpeg', // 来自「插入在线图片」的稻壳素材的图片 IsKeepShapeSize: true, }); }
Shape
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item()
获取绘图层中的单个对象,例如自选图形、任意多边形、OLE对象或图片。
JS-SDK V1.1.10及以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取绘图层中的单个对象,例如自选图形、任意多边形、OLE对象或图片 const shape =await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1); }
属性
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).ActionSettings
通过ActionSettings
属性,您可以获取Shape对象中的动作设定集合。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).ActionSettings
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; // 表示 Shape 对象中的动作设定集合 const ActionSettings =await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).ActionSettings; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).AutoShapeType
通过AutoShapeType
属性,您可以设置或获取指定Shape或ShapeRange对象的形状类型。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).AutoShapeType
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取指定Shape或ShapeRange对象的形状类型 const AutoShapeType =await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).AutoShapeType; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Fill
通过Fill
属性,您可以获取指定Shape对象的填充格式属性。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Fill
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取指定Shape对象的填充格式属性 const Fill =await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Fill; }
ActivePresentation.SlideMaster.Background.Fill.Transparency
通过Transparency
属性,您可以查询和设置填充透明度。
语法
表达式.ActivePresentation.SlideMaster.Background.Fill.Transparency
表达式:文档类型应用对象
设置
Transparency
的值在[0, 1]之间可以调整背板的透明度。设置为0
表示完全透明,设置为1
表示完全不透明。示例
//@file=base.pptx async function example() { await instance.ready(); const app = instance.Application; //设置幻灯片透明度 app.ActivePresentation.SlideMaster.Background.Fill.Transparency = 0.5; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Fill.Visible
通过Visible
属性,您可以查询和设置填充是否可见。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Fill.Visible
表达式:文档类型应用对象
示例
//@file=base.pptx async function example() { await instance.ready(); const app = instance.Application; //查询填充是否可见 await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Fill.Visible; //设置填充是否可见 app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Fill.Visible = true; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Fill.BackColor
通过BackColor
属性,您可以查询和设置填充背景色。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Fill.BackColor
表达式:文档类型应用对象
示例
//@file=base.pptx async function example() { await instance.ready(); const app = instance.Application; //查询填充背景色 await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Fill.BackColor.RGB; //设置填充背景色 app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Fill.BackColor = '#ff0000'; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Fill.ForeColor
通过ForeColor
属性,您可以查询和设置填充前景色。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Fill.ForeColor
表达式:文档类型应用对象
示例
//@file=base.pptx async function example() { await instance.ready(); const app = instance.Application; //查询填充前景色 await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Fill.ForeColor.RGB; //设置填充前景色 app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Fill.ForeColor = '#ff0000'; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Fill.Type
通过Type
属性,您可以查询填充类型。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Fill.Type
表达式:文档类型应用对象
示例
//@file=base.pptx async function example() { await instance.ready(); const app = instance.Application; //查询填充类型 await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Fill.Type; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Line
通过Line
属性,您可以获取形状的描边格式。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Line
表达式:文档类型应用对象
示例
//@file=base.pptx async function example() { await instance.ready(); const app = instance.Application; //描边对象 const lineFormat = await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Line; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Line.Transparency
通过Transparency
属性,您可以查询和设置填充透明度。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Line.Transparency
表达式:文档类型应用对象
设置
Transparency
的值在[0, 1]
之间可以调整透明度。设置为0
表示完全不透明,设置为1
表示完全透明。示例
//@file=base.pptx async function example() { await instance.ready(); const app = instance.Application; //查询透明度 await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Line.Transparency; //设置透明度 app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Line.Transparency = 0.5; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Line.Visible
通过Visible
属性,您可以查询和设置描边是否可见。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Line.Visible
表达式:文档类型应用对象
示例
//@file=base.pptx async function example() { await instance.ready(); const app = instance.Application; //查询描边是否可见 await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Line.Visible; //设置描边是否可见 app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Line.Visible = true; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Line.BackColor
通过BackColor
属性,您可以查询和设置描边背景色。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Line.BackColor
表达式:文档类型应用对象
示例
//@file=base.pptx async function example() { await instance.ready(); const app = instance.Application; //查询描边背景色 await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Line.BackColor.RGB //设置描边背景色 app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Line.BackColor = '#ff0000'; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Line.Style
通过Style
属性,您可以查询和设置描边类型。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Line.Style
表达式:文档类型应用对象
示例
//@file=base.pptx async function example() { await instance.ready(); const app = instance.Application; //查询描边线条类型 await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Line.Style; //设置描边线条类型 app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Line.Style = await app.Enum.MsoLineStyle.msoLineThickThin; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Line.DashStyle
通过DashStyle
属性,您可以查询和设置描边虚线类型。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Line.DashStyle
表达式:文档类型应用对象
示例
//@file=base.pptx async function example() { await instance.ready(); const app = instance.Application; //查询描边虚线类型 await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Line.DashStyle; //设置描边虚线类型 app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Line.DashStyle = await app.Enum.MsoLineDashStyle.msoLineDashDot; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Glow
通过Glow
属性,您可以获取指定Shape对象的发光格式。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Glow
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取指定Shape对象的发光格式 const Glow = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Glow; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).TextFrame
通过TextFrame
属性,您可以获取Shape对象中的文本框架,包含文本框架中的文本以及控制文本框架对齐和定位的属性和方法。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).TextFrame
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //可以获取Shape对象中的文本框架,包含文本框架中的文本以及控制文本框架对齐和定位的属性和方法 const TextFrame = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).TextFrame; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).HasTextFrame
通过HasTextFrame
属性,您可以查看指定Shape对象是否有文本框。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).HasTextFrame
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //查看指定Shape对象是否有文本框 const HasTextFrame = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).HasTextFrame; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Height
通过Height
属性,您可以获取指定Shape对象的高度。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Height
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取指定Shape对象的高度 const Height = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Height; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Width
通过Width
属性,您可以获取指定Shape对象的宽度。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Width
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取指定Shape对象的宽度 const Width = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Width; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Top
获取和设置从形状边界框的上边缘到幻灯片上边缘的距离。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Top
表达式:文档类型应用对象
示例
//@file=base.pptx async function example() { await instance.ready(); const app = instance.Application; // 返回/设置从形状边界框的上边缘到幻灯片上边缘的距离 const Top = await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Top; app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Top = 10; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Left
通过Left
属性,您可以获取从指定Shape对象边界框的左边缘到幻灯片左边缘的距离。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Left
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取从指定Shape对象边界框的左边缘到幻灯片左边缘的距离 const Left = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Left; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Rotation
通过Rotation
属性,您可以获取指定Shape对象绕Z轴旋转的角度。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Rotation
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取指定Shape对象绕Z轴旋转的角度 const Rotation = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Rotation; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Tags
通过Tags
属性,您可以获取一个表示指定Shape对象的标签的Tags对象。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Tags
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取一个表示指定Shape对象的标签的Tags对象 const Tags = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Tags; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Type
通过Type
属性,您可以获取单个Shape对象或ShapeRange内多个Shape对象的类型。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Type
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取单个Shape对象的类型 const Type = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Type; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Shadow
通过Shadow
属性,您可以获取指定Shape对象的阴影格式。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(Index).Shadow
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取指定Shape对象的阴影格式 const Shadow = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).Shadow; }
ShapeRange
ActiveWindow.Selection.ShapeRange
获取选定区域中Shape对象的集合。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActiveWindow.Selection.ShapeRange
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取演示文稿对象 const presentation = await app.ActiveWindow.Selection; //获取选定区域中Shape对象的集合 const view = await presentation.ShapeRange; }
方法
ActiveWindow.Selection.ShapeRange.Item()
通过Item()
方法,您可以获取单个Shape对象。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActiveWindow.Selection.ShapeRange.Item(Index)
表达式:文档类型应用对象
参数
属性
数据类型
是否必填
描述
Index
Number
是
Shape对象序列号。
示例
async function example() { await instance.ready(); const app = instance.Application; //获取演示文稿对象 const presentation = await app.ActiveWindow.Selection; //获取选定区域中Shape对象的集合 const view = await presentation.ShapeRange; //获取选定区域中的单个Shape对象 await app.ActiveWindow.Selection.ShapeRange.Item(1); }
属性
ActiveWindow.Selection.ShapeRange.Count
通过Count
属性,您可以获取选定区域中的Shape数量。
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActiveWindow.Selection.ShapeRange.Count
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取演示文稿对象 const presentation = await app.ActiveWindow.Selection; //获取选定区域中Shape对象的集合 const view = await presentation.ShapeRange; //获取选定区域中的Shape数量 const count = await app.ActiveWindow.Selection.ShapeRange.Count console.log(count); }
TextFrame
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().TextFrame
获取Shape对象中的文本框架,包含文本框架中的文本以及控制文本框架对齐和定位的属性和方法。
JS-SDK V1.1.10以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().TextFrame
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取Shape对象中的文本框架,包含文本框架中的文本以及控制文本框架对齐和定位的属性和方法 const TextFrame = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).TextFrame; }
TextRange
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().TextFrame.TextRange
获取Shape对象中包含附加到形状的文本和用于操作文本的属性和方法。
JS-SDK V1.1.10以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().TextFrame.TextRange
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取Shape对象中包含附加到形状的文本和用于操作文本的属性和方法 const TextRange = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().TextFrame.TextRange; }
属性
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().TextFrame.TextRange.Text
通过Text
属性,您可以设置一个字符串表示包含指定Shape对象的文本。
JS-SDK V1.1.10以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().TextFrame.TextRange.Text
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //设置一个字符串表示包含指定Shape对象的文本 app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().TextFrame.TextRange.Text = 'Aliyun'; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(index).TextFrame.TextRange.Font
通过Font
属性,您可以返回一个指定范围内的 Font 对象,该对象包含了指定文字的文字属性
JS-SDK V1.1.14以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(index).TextFrame.GetTextRange(Begin,End).Font
表达式:文档类型应用对象。
属性
数据类型
是否必填
描述
Begin
Number
是
文字开始位置
End
Number
是
文字结束位置
示例
async function example() { await instance.ready(); const app = instance.Application; // 返回一个指定范围内的 Font 对象,该对象包含了指定文字的文字属性 const Font = app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.Item(1).TextFrame.GetTextRang(1,2).Font; }
ActionSettings
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings
获取包含两个ActionSetting对象的集合。
JS-SDK V1.1.10以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取包含两个ActionSetting对象的集合 const ActionSettings = await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings; }
方法
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item()
获取从指定的 ActionSettings 集合设置的单个操作。
JS-SDK V1.1.10以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(Index)
表达式:文档类型应用对象。
示例
async function example() { await instance.ready(); const app = instance.Application; // 返回从指定的 ActionSettings 集合设置的单个操作 const ActionSetting = await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(1); }
ActionSetting
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item()
获取包含指定Shape对象或TextRange对象在幻灯片放映期间如何对鼠标操作做出反应的相关信息。
JS-SDK V1.1.10以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(Index)
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取包含指定Shape对象或TextRange对象在幻灯片放映期间如何对鼠标操作做出反应的相关信息 const ActionSetting = await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(1); }
属性
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item().Hyperlink
获取一个Hyperlink对象,该对象代表指定形状的超链接。此为只读属性。
JS-SDK V1.1.10以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(Index).Hyperlink
表达式:文档类型应用对象。
示例
async function example() { await instance.ready(); const app = instance.Application; // 返回一个 Hyperlink 对象,该对象代表指定形状的超链接。此为只读属性 const ActionSetting = await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(1).Hyperlink; }
Hyperlink
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(Index).Hyperlink
获取指定Shape对象的超链接。
JS-SDK V1.1.10以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(Index).Hyperlink
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //获取指定Shape对象的超链接 const ActionSetting = await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(1).Hyperlink; }
属性
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(Index).Hyperlink.TextToDisplay
通过TextToDisplay
属性,您可以设置或获取不与图形相关联的超链接的显示文本。
JS-SDK V1.1.10以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(Index).Hyperlink.TextToDisplay
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //添加文本框 const textBox = await app.Application.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox({ Orientation: -1, Left: 0.3, Top: 0.3, Width: 100, Height: 30, Color: '#ff0', Size: 24, Scale: false, }); //设置显示文本 textBox.ActionSettings(1).Hyperlink.TextToDisplay = 'Aliyun知识库'; //设置超链接 textBox.ActionSettings(1).Hyperlink.Address = 'https://example.aliyundoc.com/docs'; }
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(Index).Hyperlink.Address
通过Address
属性,您可以设置或获取指定Shape对象的超链接地址。
JS-SDK V1.1.10以上版本支持此功能。
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(Index).Hyperlink.Address
表达式:文档类型应用对象
示例
async function example() { await instance.ready(); const app = instance.Application; //添加文本框 const textBox = await app.Application.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox({ Orientation: -1, Left: 0.3, Top: 0.3, Width: 100, Height: 30, Color: '#ff0', Size: 24, Scale: false, }); //设置显示文本 textBox.ActionSettings(1).Hyperlink.TextToDisplay = 'Aliyun'; //设置超链接 textBox.ActionSettings(1).Hyperlink.Address = 'https://example.aliyundoc.com/docs'; //获取超链接地址 const address = await app.ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddTextbox().ActionSettings.Item(1).Hyperlink.Address }3