This article will talk about how to convert PPT to PDF. In such cases, it is a good alternative to convert the PPT to a PDF file and display it to your audience. It is already too late to fix the Office problem at the moment. Imagine you are about to give a lecture with your PPT document but the displaying computer fails to open its Microsoft Office PowerPoint.
However, to display it, you must have a computer with a fine Microsoft Office on it. You can carefully prepare your PPT before giving a lecture or speech. Newname = os.path.join(outputdir,newname)įiles = glob.glob(os.path.join(dir,"*.PowerPoint is a handy tool to give demonstrations. Outputdir = r"C:\Users\Paul\Documents\web\ykfp\Par16\Presentations\pdf" I suppose if you wanted to avoid overwrite, you would have to use try-except somehow. By default, the SaveAs overwrites files in the output directory if they already exist, which is fine by me. I tried a couple times to get lines 13 -15 combined into one line, but I don't have time for that kind of elegance. Now the pdf files are written to a different folder, outputdir. #for file in [ ppt for ppt in os.listdir(dir)įiles = glob.glob(os.path.join(dir,"*.ppt*")) Now if I can just direct the output files to a different folder, I'll be done.ĭir = r"C:\Users\Paul\Documents\web\ykfp\Par16\Presentations\YBSMC 2016 Thursday"
Your suggestion to change ppt? to ppt worked well to pick up both the old and the new file extensions. PowerPoint opens up, shows a little "publishing" progress bar for each input file, then Powerpoint shuts down. I'll read up on this.) So I replaced the sys.argv with my dir variable in line 25, and it ran. (Still, I don't understand entirely how this magic works. I set the path explicitly, then got side tracked with a for loop to test the list contents, lines 18 - 23, now commented out, and when that part showed me a good list of files, I almost put lines 25- 27 in the for loop, but then thought, hey that's what the glob.glob part is supposed to do. Thanks, Darren, that's a lot like what I came up with on my own. 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. Running the script in pythonwin made it easier to insert an input file name as argv, and I didn't hit any of the win32 errors.
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. 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.
Newname = os.path.splitext(filename) + ".pdf"ĭeck = (filename)įiles = glob.glob(os.path.join(sys.argv,"*.ppt?"))įirst I tried running the script in IDLE, but first hit No module named, then after I installed pywin extensions for python 27, 32 bit, I got ImportError: No module named win32api. If I can see this run once then I can extend it to loop through the whole folder and write to different output folder.
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. This isn't a GIS question, but I thought maybe someone could help.