0

I am trying to use the function proposed by @Zeynel which is the following function:

    def mergePresentations(inputFileNames, outputFileName):

        Application = win32com.client.Dispatch("PowerPoint.Application")
        outputPresentation = Application.Presentations.Add()
        outputPresentation.SaveAs(outputFileName)

        for file in inputFileNames:
            currentPresentation = Application.Presentations.Open(file)
            currentPresentation.Slides.Range(range(1, currentPresentation.Slides.Count + 1)).copy()
            Application.Presentations(outputFileName).Windows(1).Activate()
            outputPresentation.Application.CommandBars.ExecuteMso("PasteSourceFormatting")
            currentPresentation.Close()

        outputPresentation.save()
        outputPresentation.close()
        Application.Quit()

However I keep getting the following error: AttributeError: Open.Close Where the ppt file Does not close by the win32com library and stops the whole merging process. Any idea about the cause of the problem and how to solve?

  • Maybe try adding the optional readOnly=true parameter to the Open() call? You also try Application.DisplayAlerts = False – DS_London May 07 '22 at 09:24
  • @DS_London I tried both your solution but still I have the same problem. btw, this problem occurs more frequently when I have more presentations to merge. – Ahmed Ben Soltane May 16 '22 at 08:58

0 Answers0