This isn't a GIS question, but I thought maybe someone could help. I have a couple folders of PowerPoint files that I need to convert to PDF files, and I thought it would help me practice some python to see if I could script this task. I found an example at http://odetocode.com/blogs/scott/archive/2013/06/26/convert-a-directory-of-powerpoint-slides-to-pdf-with-python.aspx
that I am using as a starting point. If I can see this run once then I can extend it to loop through the whole folder and write to different output folder.
import sys
import os
import glob
import win32com.client
def convert(files, formatType = 32):
powerpoint = win32com.client.Dispatch("Powerpoint.Application")
powerpoint.Visible = 1
for filename in files:
newname = os.path.splitext(filename)[0] + ".pdf"
deck = powerpoint.Presentations.Open(filename)
deck.SaveAs(newname, formatType)
deck.Close()
powerpoint.Quit()
files = glob.glob(os.path.join(sys.argv[1],"*.ppt?"))
convert(files)
First I tried running the script in IDLE, but first hit No module named win32.com, then after I installed pywin extensions for python 27, 32 bit, I got ImportError: No module named win32api. Looking through posts at Geonet, I found that I was having this problem with win32 back in 2006, and the easy way out is to run it in PythonWin. I'm running ArcGIS 10.3.1 on a 64 bit Windows system, so it looks like python 2.7.8, so I tried the install of win32 2.7 32 bit.
Running the script in pythonwin made it easier to insert an input file name as argv[1], and I didn't hit any of the win32 errors. But it seemed to run to completion, giving "returned exit code 0" in the PythonWin bottom bar, but I can't find any output pdf file on my system. What happened?