我有一个 powerpoint 文件,并从中提取了一张幻灯片。现在我想将这张幻灯片另存为一个新文件。我正在使用 python-pptx 库。
我的尝试如下:
prs = Presentation('MyPPTFile.pptx') //get PowerPoint file
slide_to_save = prs.slides[0]
new_presentation = Presentation()
new_slide = new_presentation.slides.add_slide(slide_to_save.slide_layout)
for shape in slide_to_save.shapes:
new_shape = new_slide.shapes.add_shape(shape.auto_shape_type, shape.left, shape.top, shape.width, shape.height)
new_shape.text = shape.text
new_presentation.save('presentation.pptx') //save this as a new file
当我尝试这个时,我收到一条错误消息:“AttributeError:‘GraphicFrame’对象没有属性‘auto_shape_type’”。
有更简单的方法吗?这很简单,但我遇到了很多问题。