This article mainly introduced the Python implementation to the PPT file inserts the new slide page The method, involves the Python operation PPT document to add the slide the related skill, very has the practical value, needs the friend to be possible to refer to under
This example describes how Python implements a new slide page in a ppt file. Share to everyone for your reference. The implementation methods are as follows:
|1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17-18||#-*-coding:utf-8-*-import win32com.client import win32com.client.dynamic import os #我的示例 (Template) document name is 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) #这份 presentation to add a Slide, the position is inserted on the second page, after #也就是封面 (the first page), 12 The magic number is ... #告诉PPT that page is a 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|
I hope this article will help you with your Python programming.