本文介绍与演示文稿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