<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I use python to convert ppt to pdf? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310118#M24154</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, I think your problem is that '*.ppt?' doesn't match any 'ppt' files. '?' means &lt;STRONG&gt;one&lt;/STRONG&gt; character, '*' means &lt;STRONG&gt;zero or more&lt;/STRONG&gt; characters, so you could change to '*.ppt*' to pick up ppt and pptx.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Jun 2016 18:05:45 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2016-06-29T18:05:45Z</dc:date>
    <item>
      <title>How can I use python to convert ppt to pdf?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310114#M24150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This isn't a GIS question,&amp;nbsp; but I thought maybe someone could help.&amp;nbsp; I have a couple folders of PowerPoint files that I need to convert to PDF files,&amp;nbsp; and I thought it would help me practice some python to see if I could script this task.&amp;nbsp; I found an example at &lt;A href="http://odetocode.com/blogs/scott/archive/2013/06/26/convert-a-directory-of-powerpoint-slides-to-pdf-with-python.aspx" rel="nofollow noopener noreferrer" target="_blank"&gt;http://odetocode.com/blogs/scott/archive/2013/06/26/convert-a-directory-of-powerpoint-slides-to-pdf-with-python.aspx &lt;/A&gt;&lt;/P&gt;&lt;P&gt;that I am using as a starting point.&amp;nbsp; If I can see this run once then I can extend it to loop through the whole folder and write to different output folder.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import sys
import os
import glob
import win32com.client

def convert(files, formatType = 32):
&amp;nbsp;&amp;nbsp;&amp;nbsp; powerpoint = win32com.client.Dispatch("Powerpoint.Application")
&amp;nbsp;&amp;nbsp;&amp;nbsp; powerpoint.Visible = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in files:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newname = os.path.splitext(filename)[0] + ".pdf"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck = powerpoint.Presentations.Open(filename)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck.SaveAs(newname, formatType)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck.Close()
&amp;nbsp;&amp;nbsp;&amp;nbsp; powerpoint.Quit()

files = glob.glob(os.path.join(sys.argv[1],"*.ppt?"))
convert(files)
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First I tried running the script in IDLE, but first hit No module named win32.com,&amp;nbsp; then after I installed &lt;A href="https://sourceforge.net/projects/pywin32/?source=typ_redirect" rel="nofollow noopener noreferrer" target="_blank"&gt;pywin extensions&lt;/A&gt; for python 27, 32 bit,&amp;nbsp; I got ImportError: No module named win32api.&amp;nbsp; Looking through posts at Geonet, I found that I was having &lt;A _jive_internal="true" href="https://community.esri.com/thread/10205" target="_blank"&gt;this problem with win32 back in 2006&lt;/A&gt;,&amp;nbsp; and the easy way out is to run it in PythonWin.&amp;nbsp; I'm running ArcGIS 10.3.1 on a 64 bit Windows system,&amp;nbsp; so it looks like python 2.7.8, so I tried the install of win32 2.7 32 bit.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running the script in pythonwin made it easier to insert an input file name as argv[1],&amp;nbsp; and I didn't hit any of the win32 errors.&amp;nbsp; 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.&amp;nbsp; What happened?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:50:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310114#M24150</guid>
      <dc:creator>PaulHuffman</dc:creator>
      <dc:date>2021-12-11T14:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use python to convert ppt to pdf?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310115#M24151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can you add a&lt;/P&gt;&lt;P&gt;print(files)&lt;/P&gt;&lt;P&gt;line after line 16 and add one after newname to ensure that things are being found and created... or have you done this already?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2016 02:02:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310115#M24151</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-29T02:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use python to convert ppt to pdf?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310116#M24152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Print(files) after 16 gave [],&amp;nbsp; remarked that out and tried print after line 10,&amp;nbsp; got nothing out. &lt;/P&gt;&lt;P&gt;This example script doesn't set the input or output path,&amp;nbsp; so I figured it might work if I just save and run the script in the same folder that contains the PowerPoint files,&amp;nbsp; .ppt?&amp;nbsp; Maybe I'll see if I can set the path then create a list of ppt? files. Oh, skip,&amp;nbsp; I guess I can't use arcpy to set the workspace or make the list because ppt isn't an arcpy format.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2016 17:42:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310116#M24152</guid>
      <dc:creator>PaulHuffman</dc:creator>
      <dc:date>2016-06-29T17:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use python to convert ppt to pdf?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310117#M24153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'll confirm that this works for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import sys
import os
import glob
import win32com.client

def convert(files, formatType = 32):
&amp;nbsp;&amp;nbsp;&amp;nbsp; powerpoint = win32com.client.Dispatch("Powerpoint.Application")
&amp;nbsp;&amp;nbsp;&amp;nbsp; powerpoint.Visible = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in files:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newname = os.path.splitext(filename)[0] + ".pdf"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck = powerpoint.Presentations.Open(filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck.SaveAs(newname, formatType)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck.Close()
&amp;nbsp;&amp;nbsp;&amp;nbsp; powerpoint.Quit()

files = glob.glob(r'PATH_TO_MY_PPTX') # &amp;lt;--- ONLY CHANGE
convert(files)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PyScripter, Python 2.7.5&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:50:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310117#M24153</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T14:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use python to convert ppt to pdf?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310118#M24154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, I think your problem is that '*.ppt?' doesn't match any 'ppt' files. '?' means &lt;STRONG&gt;one&lt;/STRONG&gt; character, '*' means &lt;STRONG&gt;zero or more&lt;/STRONG&gt; characters, so you could change to '*.ppt*' to pick up ppt and pptx.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2016 18:05:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310118#M24154</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-06-29T18:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use python to convert ppt to pdf?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310119#M24155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Darren,&amp;nbsp; that's a lot like what I came up with on my own.&amp;nbsp; I set the path explicitly,&amp;nbsp; then got side tracked with a for loop to test the list contents,&amp;nbsp; lines 18 - 23, now commented out, and when that part showed me a good list of files,&amp;nbsp; 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. (Still, I don't understand entirely how this magic works.&amp;nbsp; I'll read up on this.)&amp;nbsp; So I replaced the sys.argv[1] with my dir variable in line 25, and it ran.&amp;nbsp; PowerPoint opens up,&amp;nbsp; shows a little "publishing" progress bar for each input file,&amp;nbsp; then Powerpoint shuts down.&amp;nbsp; Your suggestion to change ppt? to ppt worked well to pick up both the old and the new file extensions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if I can just direct the output files to a different folder, I'll be done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import sys
import os
import glob
import win32com.client

def convert(files, formatType = 32):
&amp;nbsp;&amp;nbsp;&amp;nbsp; powerpoint = win32com.client.Dispatch("Powerpoint.Application")
&amp;nbsp;&amp;nbsp;&amp;nbsp; powerpoint.Visible = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in files:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newname = os.path.splitext(filename)[0] + ".pdf"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print(files)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck = powerpoint.Presentations.Open(filename)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck.SaveAs(newname, formatType)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck.Close()
&amp;nbsp;&amp;nbsp;&amp;nbsp; powerpoint.Quit()

dir =&amp;nbsp; r"C:\Users\Paul\Documents\web\ykfp\Par16\Presentations\YBSMC 2016 Thursday"
##filelist = []
##for file in [ ppt for ppt in os.listdir(dir)
##if ppt.endswith("ppt")]:
##&amp;nbsp;&amp;nbsp;&amp;nbsp; filelist.append(file)
##&amp;nbsp;&amp;nbsp;&amp;nbsp; 
#print filelist
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
files = glob.glob(os.path.join(dir,"*.ppt*"))
print(files)
convert(files)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:50:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310119#M24155</guid>
      <dc:creator>PaulHuffman</dc:creator>
      <dc:date>2021-12-11T14:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use python to convert ppt to pdf?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310120#M24156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got it to work satisfactorily.&amp;nbsp; Now the pdf files are written to a different folder, outputdir.&amp;nbsp; 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.&amp;nbsp; By default, the SaveAs overwrites files in the output directory if they already exist, which is fine by me.&amp;nbsp; I suppose if you wanted to avoid overwrite, you would have to use try-except somehow.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import sys
import os
import glob
import win32com.client

dir =&amp;nbsp; r"C:\Users\Paul\Documents\web\ykfp\Par16\Presentations\YBSMC 2016 Thursday"
outputdir = r"C:\Users\Paul\Documents\web\ykfp\Par16\Presentations\pdf"

def convert(files, formatType = 32):
&amp;nbsp;&amp;nbsp;&amp;nbsp; powerpoint = win32com.client.Dispatch("Powerpoint.Application")
&amp;nbsp;&amp;nbsp;&amp;nbsp; powerpoint.Visible = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in files:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newname = os.path.splitext(filename)[0] + ".pdf"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newname = os.path.split(newname)[1] 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newname = os.path.join(outputdir,newname)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck = powerpoint.Presentations.Open(filename)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck.SaveAs(newname, formatType)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck.Close()
&amp;nbsp;&amp;nbsp;&amp;nbsp; powerpoint.Quit()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
files = glob.glob(os.path.join(dir,"*.ppt*"))
#print(files)
convert(files)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:50:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310120#M24156</guid>
      <dc:creator>PaulHuffman</dc:creator>
      <dc:date>2021-12-11T14:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use python to convert ppt to pdf?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310121#M24157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;I wouldn't worry about the one-liner for something like that. It doesn't exactly help readability:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1467237344847828 jive_text_macro" data-renderedposition="58.906246185302734_7.997159004211426_1332_15" jivemacro_uid="_1467237344847828"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;newname = os.path.join(outputdir,&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;os.path.split(&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;os.path.splitext(filename)[&lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;] + &lt;/SPAN&gt;&lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;".pdf"&lt;/SPAN&gt;)[&lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;]&lt;/SPAN&gt;) # untested&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2016 21:55:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310121#M24157</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-06-29T21:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use python to convert ppt to pdf?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310122#M24158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does it lack style to use newname three times and to use newname to define a new version of newname?&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2016 23:27:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-convert-ppt-to-pdf/m-p/310122#M24158</guid>
      <dc:creator>PaulHuffman</dc:creator>
      <dc:date>2016-06-29T23:27:14Z</dc:date>
    </item>
  </channel>
</rss>

