Created
December 10, 2011 04:39
-
-
Save goghvanmr/1454600 to your computer and use it in GitHub Desktop.
Simple Wallpaper maker using PPT Com API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import win32com.client as win32 | |
fileDir = 'D:/Documents/Python/pythonic/python_ppt/' | |
fileName = 'wallpaper.pptx' | |
def add_wallpaper_slides(): | |
text = raw_input('Input the text:') | |
# Open Powerpoint Application | |
app = 'PowerPoint' | |
pptApp = win32.Dispatch('%s.Application' % app) | |
# Open the existing wallpaper ppt | |
pptWp = pptApp.Presentations.Open('%s%s' % (fileDir, fileName)) | |
# Copy the last slide and make a paste | |
slides = pptWp.Slides | |
count = slides.Count | |
slides[0].Copy() | |
slides.Paste(count+1) | |
# Make change to last slide | |
lastSlide = pptWp.Slides[count] | |
lastSlide.Shapes[0].TextFrame.TextRange.Text = text | |
# Save as jpg img | |
imgFileName = '_'.join(text.split()) | |
lastSlide.Export('%s%s.jpg' % (fileDir, imgFileName), 'JPG') | |
# Save the ppt and quit | |
pptWp.Save() | |
pptWp.Close() | |
pptApp.Quit() | |
if __name__ == '__main__': | |
add_wallpaper_slides() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment