How do I use Python to automatically generate a simple PowerPoint example?
I am trying to reproduce the result of the example file provided by Professor Zhao using Enthought Canopy:
http://www.shengdongzhao.com/shen_blog/how-to-automatically-create-powerpoint-slides-using-python/
I seem to have the same problem as others (and seems to still have) which you can see in the comments below the linked blog post. I understand prof. Zhao mentions that the error can be caused by improper installation of the environment. I thought it might have something to do with environment variables not being specified correctly. I tried the first answer to the following, but it looks like it prevents even opening the canopy (something not like me)
How to add to pythonpath on Windows 7?
So what is left for me to do: I open its scripts in Canopy and then run MSO.py and then MSPPT.py and then MSPPTUtil.py. Then when I run CreateSlideExamples.py (photo.JPG directory updated) I only get one table slide slide
The console is littered with the following list of errors:
%run C:/Users/dirkh_000/AppData/Local/Temp/Temp1_MSPPT.zip/MSO.py
%run "C:/Users/dirkh_000/Documents/Python scripts/Auto pp example/MSPPT.py"
%run "C:/Users/dirkh_000/Documents/Python scripts/Auto pp example/MSPPTUtil.py"
%run "C:/Users/dirkh_000/Documents/Python scripts/Auto pp example/CreateSlideExamples.py"
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
C:\Users\dirkh_000\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.4.1.1975.win-x86_64\lib\site-packages\IPython\utils\py3compat.pyc in execfile(fname, glob, loc)
195 else:
196 filename = fname
--> 197 exec compile(scripttext, filename, 'exec') in glob, loc
198 else:
199 def execfile(fname, *where):
C:\Users\dirkh_000\Documents\Python scripts\Auto pp example\CreateSlideExamples.py in <module>()
40
41 # step 3: show the slide
---> 42 presentation.create_show()
43
44 # Now you can save the slide somewhere
C:\Users\dirkh_000\Documents\Python scripts\Auto pp example\MSPPTUtil.pyc in create_show(self, visible)
45 if visible:
46 slide.select() #bring slide to front
---> 47 slide.format_slide()
48 def save_as(self, file_name):
49 self.presentation.SaveAs(file_name)
C:\Users\dirkh_000\Documents\Python scripts\Auto pp example\MSPPTUtil.pyc in format_slide(self)
64 self.slide.Select()
65 def format_slide(self):
---> 66 self.format_content()
67 self.format_title()
68 def format_title(self):
C:\Users\dirkh_000\Documents\Python scripts\Auto pp example\MSPPTUtil.pyc in format_content(self)
252 if self.title:
253 #add title
--> 254 title_range = slide.Shapes[0].TextFrame.TextRange
255 title_range.Text = self.title
256 title_range.Font.Bold = True
C:\Users\dirkh_000\AppData\Local\Enthought\Canopy\User\lib\site-packages\win32com\client\__init__.pyc in __getattr__(self, attr)
463 args=self._prop_map_get_.get(attr)
464 if args is None:
--> 465 raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))
466 return self._ApplyTypes_(*args)
467
AttributeError: '<win32com.gen_py.Microsoft PowerPoint 15.0 Object Library.Shapes instance at 0x164276808>' object has no attribute '__getitem__'
Any help is appreciated. I am running windows 8.1, powerpoint 2013.
source to share
No one has answered this question yet
See similar questions:
or similar: