Home > Backend Development > Python Tutorial > python实现向ppt文件里插入新幻灯片页面的方法

python实现向ppt文件里插入新幻灯片页面的方法

WBOY
Release: 2016-06-10 15:13:57
Original
2539 people have browsed it

本文实例讲述了python实现向ppt文件里插入新幻灯片页面的方法。分享给大家供大家参考。具体实现方法如下:

# -*- coding: UTF-8 -*-
import win32com.client
import win32com.client.dynamic
import os
#我的示例(Template)文档名为 BugCurve.pptx
def PowerPoint():
  ppt = os.path.join(os.getcwd(), "BugCurve.pptx")
  App = win32com.client.Dispatch("PowerPoint.Application")
  App.Visible = True
  Presentation = App.Presentations.Open(ppt)
  mySlide = Presentation.Slides.Add(2, 12)
  #这份 Presentation 要增加一张 Slide, 位置就插入在第二页,
  #也就是封面(第一页)之后, 12 这个神奇的数字就是..
  #告诉PPT 那一页是空白的页面
  img = os.path.join(os.getcwd(), "This_is_Picture.png")
  shape = mySlide.Shapes.AddPicture(img,LinkToFile=False,SaveWithDocument=True,Left=40,Top=100,Width=650,Height=400)
  #mySlide 中要增加一个 框框(shape)指定那个框框的大小和位置, 
  #然后那个 shape 內容要放入图形
Copy after login

希望本文所述对大家的Python程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template