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.