Python implements a way to insert a new slide page into a ppt file

Source: Internet
Author: User
Tags blank page
The example in this article describes how Python implements inserting new slide pages into PPT files. Share to everyone for your reference. The implementation method is as follows:

#-*-Coding:utf-8-*-import win32com.clientimport win32com.client.dynamicimport os# My sample (Template) document is named Bugcurve.pptxdef 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, two)  #这份 Presentation to add a Slide, the position is inserted on the second page,  #也就是封面 (First page), the magic number 12 is:  #告诉PPT that page is blank page  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 to add a box (shape) Specify the size and position of the box,   #然后那个 shape to fit into the shape

Hopefully this article will help you with Python programming.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.