4.5向幻灯片添加对象

12.1.2小节向幻灯片添加了一条直线段。实际上,可以向幻灯片添加文本、表格、图形、图表、音频和视频等内容。

下面代码向第一个幻灯片添加一个文本:

code.python
>>> sld=pr.Slides(1)
>>> shp=sld.Shapes.AddLabel(1,100,20,200,100)
>>> shp.TextFrame.TextRange.Text='123abc文本测试'

向幻灯片添加一个表格:

code.python
>>> sld.Shapes.AddTable(4,3)

向幻灯片添加一个矩形区域:

code.python
>>> sld.Shapes.AddShape(1,150,100,100,200)

向幻灯片添加一个音频:

code.python
>>> sld.Shapes.AddMediaObject2(r'D:\test.mp3',0,1,100,100)

设置效果如图4-1所示。

Document Image

图4-1 向幻灯片添加对象