pptx-修改-text_box

prs = Presentation('2017年北科建第一阶段满意度调研报告V.7.0汇报.pptx')


slide=prs.slides[2]
j=1
for shape in slide.shapes:
if not shape.has_text_frame:
continue
text_frame = shape.text_frame
print(str(j)+'=>'+text_frame.text)
j+=1
if j==8:
text_frame = shape.text_frame
text_frame.clear() # not necessary for newly-created shape

p = text_frame.paragraphs[0]
run = p.add_run()
run.text = '我的数据'

font = run.font
font.name = 'Calibri'
font.size = Pt(36)
font.bold = True
font.italic = None # cause value to be inherited from theme
font.color.rgb = RGBColor(0, 0, 0)
p1 = text_frame.add_paragraph()
text_frame.word_wrap=True
run1 = p.add_run()
run1.text = '\n保持北科建服务优势\n找出北科建关键短板\n提升北科建竞争优势'
font = run1.font
font.name = 'Calibri'
font.size = Pt(24)
font.bold = True
font.italic = None # cause value to be inherited from theme
font.color.rgb = RGBColor(0, 0, 0)
prs.save('test.pptx')
posted @ 2017-12-25 11:30  沧海一粒水  阅读(267)  评论(0编辑  收藏  举报