Jump to content

Adjusting save path for PowerPoint when using python


Nikita Belooussov

Recommended Posts

I am usingOffice.Interop.PowerPointto create a powerpoint using python. I know there is the pptx library item but I cannot use it. I am having issues with adjusting save path of the created presentation. The error I am getting is:

EnvironmentError: System.Runtime.InteropServices.COMException (0x80020011): Does not support a collection. (Exception from HRESULT: 0x80020011 (DISP_E_NOTACOLLECTION))

This is the code I am trying to use is:

import Microsoft.Office.Interop.PowerPoint as PowerPoint

powerpoint = PowerPoint.ApplicationClass()

powerpoint.Visible = True

pres=powerpoint.Presentations.Add()

filename="C:UsersmeDesktop"

pres.save(str(filename)+"\test.pptx")

I am using a different way of getting the filename, that is why I am casting it as a string, in case it was not currently one. But the output matches what is input into the variable. How would I do this correctly Thank you in advance.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...