def createpptx(mdfile, pptxfile, template): parse = Parse() parse.read(mdfile) title_name, top_subtitle, allslides = parse.get_title() prs = Presentation(template) xml_slides = prs.slides._sldIdLst removeslides = list(xml_slides) for slide in removeslides: xml_slides.remove(slide) slide = prs.slides.add_slide(prs.slide_layouts[0]) try: title = slide.shapes.title title.text = title_name subtitle = slide.placeholders[1] subtitle.text = top_subtitle except: print("No Title in template file") exit() for slides in allslides: page = Page() page.split_elem(slides) sub_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(sub_layout) shapes = slide.shapes title_shape = shapes.title body_shape = shapes.placeholders[1] title_shape.text = page.title tf = body_shape.text_frame tf.text = page.text prs.save(pptxfile)