I am using win32com library and Python to generate a PowerPoint presentation.
The presetation is created as follow:
<code>import win32com.client as win32
# Start PowerPoint
PowerPointApp = win32.gencache.EnsureDispatch("PowerPoint.Application")
PowerPointApp.Visible = True
# Create a new presentation
prs = PowerPointApp.Presentations.Add()
</code>
<code>import win32com.client as win32
# Start PowerPoint
PowerPointApp = win32.gencache.EnsureDispatch("PowerPoint.Application")
PowerPointApp.Visible = True
# Create a new presentation
prs = PowerPointApp.Presentations.Add()
</code>
import win32com.client as win32
# Start PowerPoint
PowerPointApp = win32.gencache.EnsureDispatch("PowerPoint.Application")
PowerPointApp.Visible = True
# Create a new presentation
prs = PowerPointApp.Presentations.Add()
Then I create and fill the slides. At the end I want to save it as follows
<code>prs.SaveAs("presentation.pptx")
prs.Close()
PowerPointApp.Quit()
</code>
<code>prs.SaveAs("presentation.pptx")
prs.Close()
PowerPointApp.Quit()
</code>
prs.SaveAs("presentation.pptx")
prs.Close()
PowerPointApp.Quit()
The presentation opens on the screen, the content is correct, the name is Presentation1, but I get the following error:
<code>File "C:Usersshc-userAppDataLocalTempgen_py3.1091493440-5A91-11CF-8700-00AA0060263Bx0x2x12_Presentation.py", line 202, in SaveAs
return self._oleobj_.InvokeTypes(2036, LCID, 1, (24, 0), ((8, 1), (3, 49), (3, 49)),FileName
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft PowerPoint', 'Presentation.SaveAs : An error occurred while PowerPoint was saving the file.', '', 0, -2147467259), None)
</code>
<code>File "C:Usersshc-userAppDataLocalTempgen_py3.1091493440-5A91-11CF-8700-00AA0060263Bx0x2x12_Presentation.py", line 202, in SaveAs
return self._oleobj_.InvokeTypes(2036, LCID, 1, (24, 0), ((8, 1), (3, 49), (3, 49)),FileName
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft PowerPoint', 'Presentation.SaveAs : An error occurred while PowerPoint was saving the file.', '', 0, -2147467259), None)
</code>
File "C:Usersshc-userAppDataLocalTempgen_py3.1091493440-5A91-11CF-8700-00AA0060263Bx0x2x12_Presentation.py", line 202, in SaveAs
return self._oleobj_.InvokeTypes(2036, LCID, 1, (24, 0), ((8, 1), (3, 49), (3, 49)),FileName
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft PowerPoint', 'Presentation.SaveAs : An error occurred while PowerPoint was saving the file.', '', 0, -2147467259), None)
I also tried to set
<code>PowerPointApp.Visible = False
</code>
<code>PowerPointApp.Visible = False
</code>
PowerPointApp.Visible = False
Same result. Simply, now the presentation is no more visible, of course.
I cannot fnd on Microsoft development sites any hint about this problem.